How to redirect a user to another route without redirecting the url in vanilla Express? For example, if I have routes
express = require('express'); app = express(); app.route('/old').get(function(req, res, next) { res.redirect('/new'); }); app.route('/new').get(function(req, res, next) { res.send('This is the new route'); }); app.listen(3000);
and I point my browser to http://localhost:3000/old , the application successfully redirects, and the page says This is the new route , but the URL also changed to http://localhost:3000/new . How to make the application redirect the new route, but keep the old URL ( http://localhost:3000/old )?
I am fine at installing other middleware (as if I donβt already have a million), but ideally I would like to do this without additional middleware. In addition, I do it completely in Express.js, without PHP, nginx or anything else. I will use Angular.js in my application, but this is similar to the behavior on the server side, and not on the client side. Sometimes I do client-side redirection, but I don't want to do this all the time.
redirect express
trysis
source share