Skip to content

Instantly share code, notes, and snippets.

@carlohcs
Created September 17, 2019 00:50
Show Gist options
  • Save carlohcs/bac9405075cd8906188b8a887efdc0f9 to your computer and use it in GitHub Desktop.
Save carlohcs/bac9405075cd8906188b8a887efdc0f9 to your computer and use it in GitHub Desktop.
Força o redirect para HTTPS no Heroku
function forceSSL(req, res, next) {
if (req.headers['x-forwarded-proto'] !== 'https') {
// console.log('FORCING SSL. Redirecting... ', [BASE_URL, req.url].join(''))
return res.redirect(301, [BASE_URL, req.url].join(''))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment