How do I redirect to the "current" page in node.js (No middle-ware) -


user's can log in page.

i'd have form redirect current page user on , clear post data can refresh without problems.

i can't seem figure out how it, or find how it, without using external library or middleware.

any appreciated!


edit:
there login form appears in top of every page. user may enter credentials , form's action leads itself.

the server checks see if user logging in, , if correct post variables set, sets required various session variables.

i'm wondering how can redirect user page on used login form.

since don't want use framework express, think you're either going have implement form of session management (to keep track of user came from), or use referer http header (which might not sent, though) redirect them once authenticated.

of course, you're going generate redirects yourself:

res.writehead(303, { location : req.headers.referer }); res.end(); 

or, if you're not using separate uri credentials posted (like /login), want 'reload' current page, can use this:

res.writehead(303, { location : req.url }); res.end(); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -