Skip to content

Commit 0273958

Browse files
coderarityindexzero
authored andcommitted
Use changeOrigin for proxyRequest.
1 parent 04ce49c commit 0273958

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
216216
outgoing.path = req.url;
217217
outgoing.headers = req.headers;
218218

219+
//
220+
// If the changeOrigin option is specified, change the
221+
// origin of the host header to the target URL! Please
222+
// don't revert this without documenting it!
223+
//
224+
if(this.changeOrigin)
225+
outgoing.headers.host = this.target.host + ':' + this.target.port;
226+
219227
//
220228
// Open new HTTP request to internal resource with will act
221229
// as a reverse proxy pass

0 commit comments

Comments
 (0)