Skip to content

Instantly share code, notes, and snippets.

@b10s
Created June 12, 2019 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b10s/14825eef661eca58f31c5ae2fddd650d to your computer and use it in GitHub Desktop.
Save b10s/14825eef661eca58f31c5ae2fddd650d to your computer and use it in GitHub Desktop.
node express based app: redirect http to https
...
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