Im using the reverse proxy from the following link, currently Im getting some location and I want to update it(the location), How can I do that?
proxy.on('proxyRes', function (proxyRes, req, res) {
res.headers.location = 'http:/a/b/'
});
and I need to change it for example to be
res.headers.location = 'http:/c/d/' I will handle the logic how to change the URL but I want to know how to update it...
https://github.com/nodejitsu/node-http-proxy
in order to change the location headers try using res.location()
proxy.on('proxyRes', function (proxyRes, req, res) {
res.location('http:/c/d/');
});
res.location
just sets the response header. It does not set a response status code or close the response, so you can write a response body it you want, and you have to call res.end()
on your own after.
Reference: Express Location , the source
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With