Skip to content
Permalink
Browse files

[fix] be defensive and ensure location is in headers before running u…

…rl.parse()
  • Loading branch information...
jcrugzz committed Nov 25, 2014
1 parent 48ae5d8 commit 8d68ac0e0fa3080b31580aa08e92a46cc1f27696
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/http-proxy/passes/web-outgoing.js
@@ -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();

0 comments on commit 8d68ac0

Please sign in to comment.
You can’t perform that action at this time.