Skip to content

Instantly share code, notes, and snippets.

@koush
Created August 13, 2012 02:36
Show Gist options
  • Save koush/3336498 to your computer and use it in GitHub Desktop.
Save koush/3336498 to your computer and use it in GitHub Desktop.
Make node.js express respect x-forwarded-proto on res.redirect
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
// use this to let express know it is on a encrypted connection
app.use(function(req, res, next) {
var schema = req.headers["x-forwarded-proto"];
if (schema === "https") {
req.connection.encrypted = true;
}
next();
});
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
@moorejared97
Copy link

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment