Skip to content

Instantly share code, notes, and snippets.

@barbagrigia
Forked from koush/app.js
Created July 30, 2018 22:49
Show Gist options
  • Save barbagrigia/162933f5cdddfd78d542c34021ce4278 to your computer and use it in GitHub Desktop.
Save barbagrigia/162933f5cdddfd78d542c34021ce4278 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'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment