Skip to content

Commit 62201a0

Browse files
committed
Fix #95 Don't look on req.connection if it's not set.
1 parent 1389b70 commit 62201a0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: lib/node-http-proxy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
428428
// * `x-forwarded-proto`: Protocol of the original request
429429
// * `x-forwarded-port`: Port of the original request.
430430
//
431-
if (options.enableXForwarded === true) {
431+
if (options.enableXForwarded === true && req.connection) {
432432
req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.connection.socket.remoteAddress;
433433
req.headers['x-forwarded-port'] = req.connection.remotePort || req.connection.socket.remotePort;
434434
req.headers['x-forwarded-proto'] = res.connection.pair ? 'https' : 'http';

0 commit comments

Comments
 (0)