Skip to content

Commit

Permalink
[fix] be defensive and ensure location is in headers before running u…
Browse files Browse the repository at this point in the history
…rl.parse()
  • Loading branch information
jcrugzz committed Nov 25, 2014
1 parent 48ae5d8 commit 8d68ac0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/http-proxy/passes/web-outgoing.js
Expand Up @@ -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();
Expand Down

0 comments on commit 8d68ac0

Please sign in to comment.