mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[api] add prependPath option to go with path change
This commit is contained in:
parent
d1facd52c3
commit
9a534c6ff6
@ -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>
|
||||
* }
|
||||
*
|
||||
|
||||
@ -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 || '')
|
||||
: '';
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user