Skip to content

Instantly share code, notes, and snippets.

@RabidFire

RabidFire/app.js Secret

Created October 10, 2012 14:30
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 RabidFire/7f01bb6c749b3c8bd089 to your computer and use it in GitHub Desktop.
Save RabidFire/7f01bb6c749b3c8bd089 to your computer and use it in GitHub Desktop.
// My login page is getting a redirect loop. This wasn't happening on AWS though.
app.get('/login', forceHttps, users.login);
// I know for sure this function 'forceHttps' is the issue, because I changed this...
app.get('/privacy', routes.privacy);
// ... to this ...
app.get('/privacy', forceHttps, routes.privacy);
// ... and the privacy page is also having the redirect loop now.
// code
function forceHttps(req, res, next){
if ('development' !== app.get('env') && !req.connection.encrypted) {
return res.redirect('https://' + req.headers.host + req.url);
}
return next();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment