header('host'))->first(); if ($space) { if (!str_ends_with($space->host, config('app.root_domain'))) { return abort(503, 'The APP_ROOT_DOMAIN configured does not match with the current root domain'); } Config::set('app.url', '://' . $space->host); Config::set('app.sip_domain', $space->domain); $request->request->set('resolvedSpace', $space); return $next($request); } return abort(404, 'Host not configured'); } }