Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Mar 5, 2024
1 parent fc8d633 commit e924f9c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface Option {
to?: string // domain to proxy to, defaults to stacks.localhost
keyPath?: string // absolute path to the key
certPath?: string // absolute path to the cert
httpsRedirect?: boolean // redirect http to https, defaults to true
}

type Options = Option | Option[]
Expand Down Expand Up @@ -85,6 +86,11 @@ function setupReverseProxy({ key, cert, hostname, port, option }: { key: Buffer,
})

// http to https redirect
if (option.httpsRedirect ?? true)
startHttpRedirectServer()
}

function startHttpRedirectServer(): void {
http.createServer((req, res) => {
res.writeHead(301, { Location: `https://${req.headers.host}${req.url}` })
res.end()
Expand Down

0 comments on commit e924f9c

Please # to comment.