Skip to content

Commit 9a534c6

Browse files
committed
[api] add prependPath option to go with path change
1 parent d1facd5 commit 9a534c6

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

lib/http-proxy.js

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module.exports.createProxyServer =
3838
* xfwd : <true/false, adds x-forward headers>
3939
* secure : <true/false, verify SSL certificate>
4040
* toProxy: <true/false, explicitly specify if we are proxying to another proxy>
41+
* prependPath: <true/false, Default: true - specify whether you want to prepend the target's path to the proxy path>
4142
* localAddress : <Local interface string to bind for outgoing connections>
4243
* }
4344
*

lib/http-proxy/common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
6161

6262
// the final path is target path + relative path requested by user:
6363
var target = options[forward || 'target'];
64-
var targetPath = target
64+
var targetPath = target && options.prependPath !== false
6565
? (target.path || '')
6666
: '';
6767

lib/http-proxy/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ httpProxy.createRightProxy = createRightProxy;
8989
function ProxyServer(options) {
9090
EE3.call(this);
9191

92+
options = options || {};
93+
options.prependPath = options.prependPath === false ? false : true;
94+
9295
this.web = this.proxyRequest = createRightProxy('web')(options);
9396
this.ws = this.proxyWebsocketRequest = createRightProxy('ws')(options);
9497
this.options = options;

0 commit comments

Comments
 (0)