Skip to content

informative error when host cannot be determined for http->https redirect #295

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Mar 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bin/configurable-http-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,16 @@ if (options.redirectPort && listen.port !== 80) {
var redirectPort = options.redirectTo ? options.redirectTo : listen.port;
var server = http
.createServer(function (req, res) {
if (typeof req.headers.host === "undefined") {
res.statusCode = 400;
res.write(
"This server is HTTPS-only on port " +
redirectPort +
", but an HTTP request was made and the host could not be determined from the request."
);
res.end();
return;
}
var host = req.headers.host.split(":")[0];

// Make sure that when we redirect, it's to the port the proxy is running on
Expand Down