Skip to content

Commit 6bfb5d7

Browse files
committed
Fix for http-party#458. Host header may cause some sites not to be proxyable with changeOrigin enabled
1 parent ebbba73 commit 6bfb5d7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
237237
// don't revert this without documenting it!
238238
//
239239
if (this.changeOrigin) {
240-
outgoing.headers.host = this.target.host + ':' + this.target.port;
240+
outgoing.headers.host = this.target.host;
241+
// Only add port information to the header if not default port
242+
// for this protocol.
243+
// See https://github.com/nodejitsu/node-http-proxy/issues/458
244+
if (this.target.port !== 443 && this.target.https ||
245+
this.target.port !== 80 && !this.target.https) {
246+
outgoing.headers.host += ':' + this.target.port;
247+
}
241248
}
242249

243250
//

0 commit comments

Comments
 (0)