Created
July 31, 2012 12:42
-
-
Save youtalk/3216781 to your computer and use it in GitHub Desktop.
Automatic redirection from HTTP to HTTPS with Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
what about body in post method?