updated protocol enforcing

This commit is contained in:
Kasper Rynning-Tønnesen
2017-05-02 18:03:14 +02:00
parent e3fba808b1
commit 1d97e9b37e

View File

@@ -8,10 +8,9 @@ router.use(function(req, res, next) {
}); });
router.route('/:channel_name').get(function(req, res, next){ router.route('/:channel_name').get(function(req, res, next){
var protocol = req.protocol;
var subdomain = req.headers['x-forwarded-host'].split("."); var subdomain = req.headers['x-forwarded-host'].split(".");
if((subdomain[0] != 'localhost' && !(subdomain.length >= 2 && subdomain[1] == 'localhost')) && protocol != "https") { if((subdomain[0] != 'localhost' && !(subdomain.length >= 2 && subdomain[1] == 'localhost'))) {
res.redirect("https://zoff.me"); res.redirect("https://zoff.me");
return; return;
} }
@@ -108,10 +107,9 @@ router.route('/api/mail').post(function(req, res) {
}); });
router.route('/').get(function(req, res, next){ router.route('/').get(function(req, res, next){
var protocol = req.protocol;
var subdomain = req.headers['x-forwarded-host'].split("."); var subdomain = req.headers['x-forwarded-host'].split(".");
if((subdomain[0] != 'localhost' && !(subdomain.length >= 2 && subdomain[1] == 'localhost')) && protocol != "https") { if((subdomain[0] != 'localhost' && !(subdomain.length >= 2 && subdomain[1] == 'localhost'))) {
res.redirect("https://zoff.me"); res.redirect("https://zoff.me");
return; return;
} }