fixed port redirect issue

This commit is contained in:
Kasper Rynning-Tønnesen
2017-05-03 18:47:57 +02:00
parent 84dd2d7b9f
commit ef6d3af3a9

View File

@@ -10,8 +10,8 @@ router.use(function(req, res, next) {
router.route('/:channel_name').get(function(req, res, next){ router.route('/:channel_name').get(function(req, res, next){
try{ try{
var url = req.headers['x-forwarded-host']; var url = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'] : req.headers.host.split(":")[0];
var subdomain = req.headers['x-forwarded-host'].split("."); var subdomain = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'].split(".") : req.headers.host.split(":")[0].split(".");
if(url != "zoff.me" && url != "remote.zoff.me" && url != "remote.localhost" && url != "localhost") { if(url != "zoff.me" && url != "remote.zoff.me" && url != "remote.localhost" && url != "localhost") {
res.redirect("https://zoff.me"); res.redirect("https://zoff.me");
return; return;
@@ -126,8 +126,8 @@ router.route('/api/mail').post(function(req, res) {
router.route('/').get(function(req, res, next){ router.route('/').get(function(req, res, next){
try{ try{
var url = req.headers['x-forwarded-host']; var url = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'] : req.headers.host.split(":")[0];
var subdomain = req.headers['x-forwarded-host'].split("."); var subdomain = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'].split(".") : req.headers.host.split(":")[0].split(".");
if(url != "zoff.me" && url != "remote.zoff.me" && url != "remote.localhost" && url != "localhost") { if(url != "zoff.me" && url != "remote.zoff.me" && url != "remote.localhost" && url != "localhost") {
res.redirect("https://zoff.me"); res.redirect("https://zoff.me");
return; return;
@@ -148,7 +148,8 @@ router.route('/').get(function(req, res, next){
res.render('layouts/frontpage', data); res.render('layouts/frontpage', data);
} }
} catch(e) { } catch(e) {
res.redirect("https://zoff.me"); console.log(e);
//res.redirect("https://zoff.me");
} }
}); });