From 59d5bc60432c959db671b8b5392840d47551f2bb Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Sat, 30 Mar 2013 17:39:25 +0100 Subject: [PATCH] Set Host header based on actual input Fixes #1 --- lib/cors-anywhere.js | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/cors-anywhere.js b/lib/cors-anywhere.js index 682ac58..5890a71 100644 --- a/lib/cors-anywhere.js +++ b/lib/cors-anywhere.js @@ -182,6 +182,9 @@ var getHandler = exports.getHandler = function(options) { delete req.headers[header]; }); + // Only add port if it was explicitly set + req.headers.host = host + (match[4] ? ':' + port : ''); + proxyRequest(req, res, proxy, full_url, { host: hostname, port: port @@ -197,7 +200,6 @@ var createServer = exports.createServer = function(options) { // Default options: var httpProxyOptions = { - changeOrigin: true, // Change Host request header to match the requested URL instead of the proxy's URL. xforward: { enable: true // Append X-Forwarded-* headers } diff --git a/package.json b/package.json index 3e8be3d..bba5d12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cors-anywhere", - "version": "0.1.1", + "version": "0.1.2", "description": "CORS Anywhere is a reverse proxy which adds CORS headers to the proxied request. Request URL is taken from the path", "license": "MIT", "author": "Rob W ",