Skip to content

Commit ca37ad7

Browse files
ryanstevensjfhbrook
authored andcommitted
[fix] x-forwarded-proto sets properly
The ternary was evaluating truthy for "," + req.connection.pair which is always true because its always a non empty string. Wrapped actual condition to properly concatenate the product of the ternary. let me know if you prefer the style (req.connection.pair ? 'https' : 'http') #250
1 parent f223ce8 commit ca37ad7

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)