mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Added possible crash-fix for subdomain-redirecting
This commit is contained in:
@@ -122,12 +122,16 @@ function onListen() {
|
|||||||
function routingFunction(req, res, next) {
|
function routingFunction(req, res, next) {
|
||||||
var client = require('./apps/client.js');
|
var client = require('./apps/client.js');
|
||||||
var admin = require('./apps/admin.js');
|
var admin = require('./apps/admin.js');
|
||||||
var url = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'] : req.headers.host.split(":")[0];
|
try {
|
||||||
var subdomain = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'].split(".") : req.headers.host.split(":")[0].split(".");
|
var url = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'] : req.headers.host.split(":")[0];
|
||||||
|
var subdomain = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'].split(".") : req.headers.host.split(":")[0].split(".");
|
||||||
|
|
||||||
if(subdomain.length > 1 && subdomain[0] == "admin") {
|
if(subdomain.length > 1 && subdomain[0] == "admin") {
|
||||||
admin(req, res, next);
|
admin(req, res, next);
|
||||||
} else {
|
} else {
|
||||||
client(req, res, next);
|
client(req, res, next);
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
res.sendStatus(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user