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

User's can log in from any page.

I'd like to have the form redirect to the current page the user is on and clear the POST data so they can refresh without problems.

I can't seem to figure out how to do it, or find how to do it, without using an external library or middleware.

Any help would be appreciated!


EDIT:
There is a login form that appears in the top of every page. The user may enter their credentials and the form's action leads to itself.

The server checks to see if a user is logging in, and if the correct POST variables are set, it sets the required various session variables.

I'm wondering how I can redirect the user to the page on which they used the login form.

Since you don't want to use a framework like Express, I think you're either going to have to implement some form of session management yourself (to keep track of where the user came from), or use the Referer HTTP header (which might not always be sent, though) to redirect them back once they are authenticated.

Of course, you're going to generate those redirects yourself:

res.writeHead(303, { Location : req.headers.referer });
res.end();

Or, if you're not using a separate URI that the credentials are posted to (like /login), but just want to 'reload' the current page, you can use this:

res.writeHead(303, { Location : req.url });
res.end();