Commit a3cb527b authored by indexzero's avatar indexzero

[api] Update `request` event to be consistent by emitting both `req` and...

[api] Update `request` event to be consistent by emitting both `req` and `res`. Add `x-forwarded-for` header.
parent c485c874
......@@ -104,7 +104,7 @@ exports.createServer = function () {
proxy = new HttpProxy(options);
server = http.createServer(function (req, res) {
proxy.emit('request', req, req.headers.host, req.url);
proxy.emit('request', req, res, req.headers.host, req.url);
// If we were passed a callback to process the request
// or response in some way, then call it.
......@@ -276,6 +276,11 @@ HttpProxy.prototype.proxyRequest = function (req, res, port, host, buffer) {
host = location.host;
}
//
// Add `x-forwarded-for` header to availible client IP to apps behind proxy
//
req.headers['x-forwarded-for'] = req.connection.remoteAddress;
//
// Emit the `start` event indicating that we have begun the proxy operation.
//
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment