Skip to content

Instantly share code, notes, and snippets.

@youtalk
Created July 31, 2012 12:42
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save youtalk/3216781 to your computer and use it in GitHub Desktop.
Save youtalk/3216781 to your computer and use it in GitHub Desktop.
Automatic redirection from HTTP to HTTPS with Node.js
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'));
});
@bander-saeed94
Copy link

what about body in post method?

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