Skip to content

Commit 8d68ac0

Browse files
committed
[fix] be defensive and ensure location is in headers before running url.parse()
1 parent 48ae5d8 commit 8d68ac0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/http-proxy/passes/web-outgoing.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ var redirectRegex = /^30(1|2|7|8)$/;
4747
},
4848

4949
function setRedirectHostRewrite(req, res, proxyRes, options) {
50-
if (options.hostRewrite && redirectRegex.test(proxyRes.statusCode)) {
50+
if (options.hostRewrite
51+
&& proxyRes.headers['location']
52+
&& redirectRegex.test(proxyRes.statusCode)) {
5153
var u = url.parse(proxyRes.headers['location']);
5254
u.host = options.hostRewrite;
5355
proxyRes.headers['location'] = u.format();

0 commit comments

Comments
 (0)