redirect Location but not URL redirect Location but not URL express express

redirect Location but not URL


rather than redirect, how about just send a get request using request module

and do a callback to update content.

var request = require('request');app.route('/old').get(function(req, res, next) {  request.get('/new', function(err, response, body) {    if (!err) {      req.send(body);    }  });         });


You can have a helper method that both routes use:

express = require('express');app = express();const newHandler = function(req, res, next) {    res.send('This is the new route');};app.route('/old').get(newHandler);app.route('/new').get(newHandler);app.listen(3000);

Note, req.url will be different inside newHandler for the two different routes, so you may need to handle that.