Skip to content

Commit 0933f1c

Browse files
committed
Fix bug: x-forwarded-proto set incorrectly
When routed via multiple proxies, x_forwarded_proto set as httphttps or wswss instead of http,https or ws,wss, since + operator seems to have a higher precedence than the terniary operator and the expression was getting evaluated to true always
1 parent 81f6095 commit 0933f1c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/node-http-proxy/http-proxy.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
148148
}
149149

150150
if (req.headers['x-forwarded-proto']){
151-
var protoToAppend = "," + (req.connection.pair) ? 'https' : 'http';
151+
var protoToAppend = "," + (req.connection.pair ? 'https' : 'http');
152152
req.headers['x-forwarded-proto'] += protoToAppend;
153153
}
154154
else {
@@ -415,7 +415,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
415415
}
416416

417417
if (req.headers['x-forwarded-proto']){
418-
var protoToAppend = "," + (req.connection.pair) ? 'wss' : 'ws';
418+
var protoToAppend = "," + (req.connection.pair ? 'wss' : 'ws');
419419
req.headers['x-forwarded-proto'] += protoToAppend;
420420
}
421421
else {

0 commit comments

Comments
 (0)