The docs says that headers can be overridden before issuing the proxyRequest with the proxyReqOptDecorater with the following code.
proxyReqOptDecorator: function(proxyReqOpts, srcReq) {
// you can update headers
proxyReqOpts.headers['Content-Type'] = 'text/html';
// you can change the method
proxyReqOpts.method = 'GET';
return proxyReqOpts;
}
but it does not seem to work as described.
let getProxy = proxy('someurl.com', {
proxyReqOptDecorator: function (proxyReqOpts, srcReq) {
srcReq.headers['X-Forwarded-For'] = 'test';
return proxyReqOpts;
}
});
Running express-http-proxy in debug mode, I observe that the 'proxy request options' and 'Request options (after processing)' both do not contain the header X-Forwarded-For.
If I were to pass the header from the client where X-Forwarded-For = not test, then the header appears in 'proxy request options'. However, after setting srcReq.headers['X-Forwarded-For'] = 'test'; the header remains unchanged in request options (after processing).
The docs says that headers can be overridden before issuing the proxyRequest with the proxyReqOptDecorater with the following code.
but it does not seem to work as described.
Running
express-http-proxy
in debug mode, I observe that the 'proxy request options' and 'Request options (after processing)' both do not contain the headerX-Forwarded-For
.If I were to pass the header from the client where
X-Forwarded-For
=not test
, then the header appears in 'proxy request options'. However, after settingsrcReq.headers['X-Forwarded-For'] = 'test';
the header remains unchanged in request options (after processing).