Skip to content

Instantly share code, notes, and snippets.

Created October 14, 2014 14:44
What would you like to do?
// author
'use strict';
module.exports = function (req, res, next) {
// we ARE deploying to Heroku. SSL termination happens at the load balancer,
// before encrypted traffic reaches your node app. It is possible to test
// whether https was used to make the request with req.headers['x-forwarded-proto'] === 'https'.
// See SOF answer by arcseldon:
if ((req.headers['x-forwarded-proto'] !== 'https') && (process.env.NODE_ENV === 'production')) {
return res.redirect([
} else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment