From f27d26f4515c900ea4cf1756ef279257a189e308 Mon Sep 17 00:00:00 2001 From: Dominic Tarr Date: Tue, 15 Nov 2011 07:41:00 +1100 Subject: [PATCH] changeOrigin option: set the host header to the proxy destination --- lib/node-http-proxy/http-proxy.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index 7279824..82bc533 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -194,7 +194,9 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { outgoing.method = req.method; outgoing.path = req.url; outgoing.headers = req.headers; - outgoing.headers.host = this.target.host + (this.target.port == 80 ? '' : ':' + this.target.port) + + if(this.changeOrigin) + outgoing.headers.host = this.target.host + (this.target.port == 80 ? '' : ':' + this.target.port) // // Open new HTTP request to internal resource with will act // as a reverse proxy pass