mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[fix] be defensive and ensure location is in headers before running url.parse()
This commit is contained in:
parent
48ae5d828c
commit
8d68ac0e0f
@ -47,7 +47,9 @@ var redirectRegex = /^30(1|2|7|8)$/;
|
||||
},
|
||||
|
||||
function setRedirectHostRewrite(req, res, proxyRes, options) {
|
||||
if (options.hostRewrite && redirectRegex.test(proxyRes.statusCode)) {
|
||||
if (options.hostRewrite
|
||||
&& proxyRes.headers['location']
|
||||
&& redirectRegex.test(proxyRes.statusCode)) {
|
||||
var u = url.parse(proxyRes.headers['location']);
|
||||
u.host = options.hostRewrite;
|
||||
proxyRes.headers['location'] = u.format();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user