How to reload current page in Express.js?

I'm current in /id/1234 page, and click a POST /add button, after that I want to reload /id/1234 in Experss.js:res.redirect(**How to get /id/1234 dynamicly, since I will be in /id/1235, /id/1236 page do a same POST /add action?**)

Thanks.

To give you the answer you probably want, the browser will send a header called [Referer][1] which will have the URL of the /id/1234 page, so do:

res.redirect(req.get('referer'));

However, your URL path design is probably poor if you need to do this. Better options might be submitting the form via AJAX without changing the URL or including the 1234 id in the form body and using that value from the POST request to generate the correct URL for the corresponding redirect.

res.redirect("/id/1234")

You just give the path (or full URI) that you wish to redirect to.

And if you're id is in the post data:

res.redirect("/id/" + req.body.id);

I'd just like to add that in the version 4.x of Express you can use

res.redirect('back');

to automatically redirect back to the page the request came from. This is the equivilant of

res.redirect(req.get('referer'));

that is mentioned in Peter Lyons answer

See also: http://expressjs.com/api.html#res.redirect