Add variable to request for user's protocol

This commit is contained in:
Jonathan Cremin 2014-12-06 14:46:30 +00:00
parent 01c7f418dc
commit da5e67f9ad
2 changed files with 6 additions and 3 deletions

5
app.js
View file

@ -52,9 +52,12 @@ app.use(function(req, res, next) {
app.get('*', function(req,res,next) {
if (req.headers['cf-visitor'] && req.headers['cf-visitor'] != '{"scheme":"https"}') {
res.redirect("https://" + req.headers['host'] + req.url);
} else if (req.headers['cf-visitor']) {
req.userProtocol = "https";
} else {
next();
req.userProtocol = "http"
}
next();
});
app.get('/', function(req, res) {