[api] add prependPath option to go with path change

This commit is contained in:
Jarrett Cruger 2014-09-11 18:42:47 -04:00
parent d1facd52c3
commit 9a534c6ff6
3 changed files with 5 additions and 1 deletions

View File

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

View File

@ -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 || '')
: '';

View File

@ -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;