diff --git a/lib/http-proxy/passes/web-outgoing.js b/lib/http-proxy/passes/web-outgoing.js index 46352f6e3..81f1e16f9 100644 --- a/lib/http-proxy/passes/web-outgoing.js +++ b/lib/http-proxy/passes/web-outgoing.js @@ -51,7 +51,8 @@ module.exports = { // <-- if ((options.hostRewrite || options.autoRewrite || options.protocolRewrite) && proxyRes.headers['location'] && redirectRegex.test(proxyRes.statusCode)) { - var target = url.parse(options.target); + const targetStr = typeof options.target === 'string' ? options.target : options.target.href; + var target = url.parse(targetStr); var u = url.parse(proxyRes.headers['location']); // make sure the redirected host matches the target host before rewriting