diff --git a/app/Http/Middleware/DatabaseLookup.php b/app/Http/Middleware/DatabaseLookup.php index 345a063805a2..b01f68e9b031 100644 --- a/app/Http/Middleware/DatabaseLookup.php +++ b/app/Http/Middleware/DatabaseLookup.php @@ -58,6 +58,11 @@ class DatabaseLookup } elseif ($guard == 'account') { if ($key = request()->account_key) { LookupAccount::setServerByField('account_key', $key); + } else { + $subdomain = Utils::getSubdomain(\Request::server('HTTP_HOST')); + if ($subdomain != 'app') { + LookupAccount::setServerByField('subdomain', $subdomain); + } } } elseif ($guard == 'license') { config(['database.default' => DB_NINJA_1]); diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 80ac648fe171..1c792ac09048 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -1002,8 +1002,12 @@ class Utils $parts = parse_url($url); $subdomain = ''; - if (isset($parts['host'])) { - $host = explode('.', $parts['host']); + if (isset($parts['host']) || isset($parts['path'])) { + if (isset($parts['host'])) { + $host = explode('.', $parts['host']); + } else { + $host = explode('.', $parts['path']); + } if (count($host) > 2) { $subdomain = $host[0]; }