From f2093b5313c855cd6309cc0ddebb31f369e525ed Mon Sep 17 00:00:00 2001 From: Torstein Thune Date: Wed, 13 Jan 2016 09:16:50 +0100 Subject: [PATCH 1/3] No longer appends / to path if ignorePath is set --- lib/http-proxy/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js index 577f9b4..d143cf9 100644 --- a/lib/http-proxy/common.js +++ b/lib/http-proxy/common.js @@ -88,7 +88,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) { // path is. This can be labeled as FOOT-GUN material if you do not know what // you are doing and are using conflicting options. // - outgoingPath = !options.ignorePath ? outgoingPath : '/'; + outgoingPath = !options.ignorePath ? outgoingPath : ''; outgoing.path = common.urlJoin(targetPath, outgoingPath); From f9540de7b13f41091be2dcb68d8f23be65ad3885 Mon Sep 17 00:00:00 2001 From: Torstein Thune Date: Wed, 13 Jan 2016 15:24:46 +0100 Subject: [PATCH 2/3] Fixed tests depending on ignorePath --- test/lib-http-proxy-common-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lib-http-proxy-common-test.js b/test/lib-http-proxy-common-test.js index 1c5fe47..e118f2e 100644 --- a/test/lib-http-proxy-common-test.js +++ b/test/lib-http-proxy-common-test.js @@ -250,7 +250,7 @@ describe('lib/http-proxy/common.js', function () { ignorePath: true }, { url: '/more/crazy/pathness' }); - expect(outgoing.path).to.eql('/some/crazy/path/whoooo/'); + expect(outgoing.path).to.eql('/some/crazy/path/whoooo'); }); it('and prependPath: false, it should ignore path of target and incoming request', function () { @@ -262,7 +262,7 @@ describe('lib/http-proxy/common.js', function () { prependPath: false }, { url: '/more/crazy/pathness' }); - expect(outgoing.path).to.eql('/'); + expect(outgoing.path).to.eql(''); }); }); From 0cb1d3c68e793fed9aa4a7624c32a018e796aa95 Mon Sep 17 00:00:00 2001 From: Torstein Thune Date: Wed, 13 Jan 2016 15:27:51 +0100 Subject: [PATCH 3/3] Added note for appending trailing / when using ignorePath --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f424a96..82fae25 100644 --- a/README.md +++ b/README.md @@ -330,7 +330,7 @@ proxyServer.listen(8015); * **secure**: true/false, if you want to verify the SSL Certs * **toProxy**: passes the absolute URL as the `path` (useful for proxying to proxies) * **prependPath**: true/false, Default: true - specify whether you want to prepend the target's path to the proxy path -* **ignorePath**: true/false, Default: false - specify whether you want to ignore the proxy path of the incoming request +* **ignorePath**: true/false, Default: false - specify whether you want to ignore the proxy path of the incoming request (note: you will have to append / manually if required). * **localAddress**: Local interface string to bind for outgoing connections * **changeOrigin**: true/false, Default: false - changes the origin of the host header to the target URL * **auth**: Basic authentication i.e. 'user:password' to compute an Authorization header.