From 9a534c6ff63d776140918bc839801d247affd18d Mon Sep 17 00:00:00 2001 From: Jarrett Cruger Date: Thu, 11 Sep 2014 18:42:47 -0400 Subject: [PATCH] [api] add prependPath option to go with path change --- lib/http-proxy.js | 1 + lib/http-proxy/common.js | 2 +- lib/http-proxy/index.js | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) 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;