Skip to content

Commit 58c0fdc

Browse files
committed
Merge pull request #934 from Torthu/master
Fix for #839 (Ignore path and the trailing slash)
2 parents d73b0d3 + 0cb1d3c commit 58c0fdc

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ proxyServer.listen(8015);
330330
* **secure**: true/false, if you want to verify the SSL Certs
331331
* **toProxy**: passes the absolute URL as the `path` (useful for proxying to proxies)
332332
* **prependPath**: true/false, Default: true - specify whether you want to prepend the target's path to the proxy path
333-
* **ignorePath**: true/false, Default: false - specify whether you want to ignore the proxy path of the incoming request
333+
* **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).
334334
* **localAddress**: Local interface string to bind for outgoing connections
335335
* **changeOrigin**: true/false, Default: false - changes the origin of the host header to the target URL
336336
* **auth**: Basic authentication i.e. 'user:password' to compute an Authorization header.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
8888
// path is. This can be labeled as FOOT-GUN material if you do not know what
8989
// you are doing and are using conflicting options.
9090
//
91-
outgoingPath = !options.ignorePath ? outgoingPath : '/';
91+
outgoingPath = !options.ignorePath ? outgoingPath : '';
9292

9393
outgoing.path = common.urlJoin(targetPath, outgoingPath);
9494

Diff for: test/lib-http-proxy-common-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ describe('lib/http-proxy/common.js', function () {
250250
ignorePath: true
251251
}, { url: '/more/crazy/pathness' });
252252

253-
expect(outgoing.path).to.eql('/some/crazy/path/whoooo/');
253+
expect(outgoing.path).to.eql('/some/crazy/path/whoooo');
254254
});
255255

256256
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 () {
262262
prependPath: false
263263
}, { url: '/more/crazy/pathness' });
264264

265-
expect(outgoing.path).to.eql('/');
265+
expect(outgoing.path).to.eql('');
266266
});
267267
});
268268

0 commit comments

Comments
 (0)