Commit 28605593 authored by Mark Stahl's avatar Mark Stahl Committed by Renée Kooi
Browse files

Fixes #509. Checks for encrypted or forwarded connection before redirecting (#510)

parent 91046961
......@@ -90,9 +90,14 @@ function createDevServer (connectionHandler) {
var location = 'https://' + host + req.url
var agent = req.headers['user-agent']
// We don't want to force an HTTPS connection if we are already
// encrypted or we are being forwarded through a proxy that may be
// taking care of it.
var encrypted = req.headers['x-forwarded-proto'] || req.connection.encrypted
// We want to force HTTPS connections, but using curl(1) or wget(1) from
// the command line can be convenient to quickly check output.
if (/^(curl|wget)/i.test(agent)) {
if (/^(curl|wget)/i.test(agent) || encrypted) {
return connectionHandler(req, res)
} else {
res.writeHead(301, { location: location })
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment