Add variable to request for user's protocol
This commit is contained in:
parent
01c7f418dc
commit
da5e67f9ad
2 changed files with 6 additions and 3 deletions
5
app.js
5
app.js
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue