Skip to content

Instantly share code, notes, and snippets.

@attomos
Forked from youtalk/redirect.http2https.js
Created July 4, 2013 03:04
Show Gist options
  • Save attomos/5924619 to your computer and use it in GitHub Desktop.
Save attomos/5924619 to your computer and use it in GitHub Desktop.
app.configure(function () {
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.configure('production', function () {
app.use (function (req, res, next) {
var schema = (req.headers['x-forwarded-proto'] || '').toLowerCase();
if (schema === 'https') {
next();
} else {
res.redirect('https://' + req.headers.host + req.url);
}
});
});
app.use(app.router);
app.use(express.static(__dirname + '/public'));
app.use(express.favicon(__dirname + '/public/favicon.ico'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment