diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index a26a68c..7e97041 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -247,7 +247,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { delete response.headers['transfer-encoding']; } - if ((response.statusCode === 301) || (response.statusCode === 302)) { + if ((response.statusCode === 301) || (response.statusCode === 302) + && typeof response.headers.location !== 'undefined') { if (self.source.https && !self.target.https) { response.headers.location = response.headers.location.replace(/^http\:/, 'https:'); }