Stop header errors on www
This commit is contained in:
parent
7468cc4ea6
commit
2241e16e5f
1 changed files with 2 additions and 2 deletions
4
app.js
4
app.js
|
@ -52,7 +52,7 @@ app.use(function(req, res, next) {
|
|||
app.get('*', function(req,res,next) {
|
||||
// force SSL
|
||||
if (req.headers['cf-visitor'] && req.headers['cf-visitor'] != '{"scheme":"https"}') {
|
||||
res.redirect("https://" + req.headers['host'] + req.url);
|
||||
return res.redirect("https://" + req.headers['host'] + req.url);
|
||||
} else if (req.headers['cf-visitor']) {
|
||||
req.userProtocol = "https";
|
||||
} else {
|
||||
|
@ -60,7 +60,7 @@ app.get('*', function(req,res,next) {
|
|||
}
|
||||
// redirect www
|
||||
if (req.headers.host.match(/^www/) !== null ) {
|
||||
res.redirect(req.userProtocol + '://' + req.headers.host.replace(/^www\./, '') + req.url);
|
||||
return res.redirect(req.userProtocol + '://' + req.headers.host.replace(/^www\./, '') + req.url);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue