Skip to content

Fix for #839 (Ignore path and the trailing slash) #934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/http-proxy/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions test/lib-http-proxy-common-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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('');
});
});

Expand Down