onReq param 2 (options) no longer the same thing in 5.x?
risacher opened this issue · 2 comments
risacher commented
The following code works for me with http2-proxy 4.2.15, but not with 5.0.30:
proxy.web(req, res,
{ onReq: (req, options, cb) => {
options.headers['x-forwarded-for'] = req.socket.remoteAddress;
options.headers['x-forwarded-port'] = req.socket.localPort;
options.headers['x-forwarded-proto'] = req.socket.encrypted ? 'https' : 'http';
options.headers['x-forwarded-host'] = req.headers['host'];
options.headers['host'] = req.headers['host'];
options.rejectUnauthorized = false;
options.trackRedirects = true;
options.host = target.host;
options.hostname = target.hostname;
options.port = target.port;
options.path = target.path;
options.protocol = target.protocol+':';
var r = (target.protocol === 'http')?
http.request(options)
: https.request(options);
return r;
},
}, defaultWebHandler );
In 5.0.30, the options parameter to onReq does not have a 'headers' entry, and in fact, equals{ onReq: [Function: onReq] }
, but this does not seem to agree with the documentation in README.md.
ronag commented
Yep, that's a bug. Try 5.0.31.