Skip to content

Commit 013cb2e

Browse files
committed
[fix] Ensure response.headers.location is defined. Fixes #276.
1 parent deca756 commit 013cb2e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/node-http-proxy/http-proxy.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
247247
delete response.headers['transfer-encoding'];
248248
}
249249

250-
if ((response.statusCode === 301) || (response.statusCode === 302)) {
250+
if ((response.statusCode === 301) || (response.statusCode === 302)
251+
&& typeof response.headers.location !== 'undefined') {
251252
if (self.source.https && !self.target.https) {
252253
response.headers.location = response.headers.location.replace(/^http\:/, 'https:');
253254
}

0 commit comments

Comments
 (0)