Skip to content

Commit 9f05e6c

Browse files
committed
Merge pull request #165 from elfsternberg/master
Fix issue where front-end is HTTPS, back-end is HTTP, and server issues a redirect.
2 parents d1b19a1 + 411bb51 commit 9f05e6c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

+9
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,15 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
232232
delete response.headers['transfer-encoding'];
233233
}
234234

235+
if ((response.statusCode === 301) || (response.statusCode === 302)) {
236+
if (self.source.https && !self.target.https) {
237+
response.headers.location = response.headers.location.replace(/^http\:/, 'https:');
238+
}
239+
if (self.target.https && !self.source.https) {
240+
response.headers.location = response.headers.location.replace(/^https\:/, 'http:');
241+
}
242+
}
243+
235244
// Set the headers of the client response
236245
res.writeHead(response.statusCode, response.headers);
237246

0 commit comments

Comments
 (0)