We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a055dbe commit e080d9bCopy full SHA for e080d9b
1 file changed
index.js
@@ -40,9 +40,13 @@ const createServer = () => {
40
/* istanbul ignore next: cannot be tested on Travis */ httpPort = 80,
41
httpsPort = process.env.PORT || 443) {
42
app.http = http.createServer((req, res) => {
43
+ const reqHost = req.headers["host"]
44
+ ? req.headers["host"].replace(":" + httpPort, "")
45
+ : /* istanbul ignore next: cannot be tested */ "localhost"
46
res.writeHead(301, {
- Location: "https://" + req.headers["host"].replace(":" + httpPort, "") +
- (httpsPort !== 443 ? ":" + httpsPort : "") + req.url
47
+ Location: "https://" + reqHost +
48
+ (httpsPort !== 443 ? ":" + httpsPort : "") + (req.url ||
49
+ /* istanbul ignore next: cannot be tested */ "")
50
})
51
res.end()
52
}).listen(httpPort)
0 commit comments