Skip to content

Commit e080d9b

Browse files
committed
Workaround for issue #16
1 parent a055dbe commit e080d9b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ const createServer = () => {
4040
/* istanbul ignore next: cannot be tested on Travis */ httpPort = 80,
4141
httpsPort = process.env.PORT || 443) {
4242
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"
4346
res.writeHead(301, {
44-
Location: "https://" + req.headers["host"].replace(":" + httpPort, "") +
45-
(httpsPort !== 443 ? ":" + httpsPort : "") + req.url
47+
Location: "https://" + reqHost +
48+
(httpsPort !== 443 ? ":" + httpsPort : "") + (req.url ||
49+
/* istanbul ignore next: cannot be tested */ "")
4650
})
4751
res.end()
4852
}).listen(httpPort)

0 commit comments

Comments
 (0)