Created
June 12, 2019 06:04
-
-
Save b10s/14825eef661eca58f31c5ae2fddd650d to your computer and use it in GitHub Desktop.
node express based app: redirect http to https
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
app.all('*', function(req, res, next){ | |
console.log('req start: ',req.secure, req.hostname, req.url, app.get('port')); | |
if (req.secure) { | |
return next(); | |
} | |
res.redirect('https://'+req.hostname + ':' + app.get('secPort') + req.url); | |
}); | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment