diff --git a/lib/http-proxy.js b/lib/http-proxy.js index bea3fe1..3fa80c8 100644 --- a/lib/http-proxy.js +++ b/lib/http-proxy.js @@ -38,6 +38,7 @@ module.exports.createProxyServer = * xfwd : * secure : * toProxy: + * prependPath: * localAddress : * } * diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js index 196a890..670a0e3 100644 --- a/lib/http-proxy/common.js +++ b/lib/http-proxy/common.js @@ -61,7 +61,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) { // the final path is target path + relative path requested by user: var target = options[forward || 'target']; - var targetPath = target + var targetPath = target && options.prependPath !== false ? (target.path || '') : ''; diff --git a/lib/http-proxy/index.js b/lib/http-proxy/index.js index 94b1849..8767dfb 100644 --- a/lib/http-proxy/index.js +++ b/lib/http-proxy/index.js @@ -89,6 +89,9 @@ httpProxy.createRightProxy = createRightProxy; function ProxyServer(options) { EE3.call(this); + options = options || {}; + options.prependPath = options.prependPath === false ? false : true; + this.web = this.proxyRequest = createRightProxy('web')(options); this.ws = this.proxyWebsocketRequest = createRightProxy('ws')(options); this.options = options;