header('host'))->first(); if ($space) { if (!str_ends_with($space->host, config('app.root_host'))) { return abort(503, 'The APP_ROOT_HOST configured does not match with the current root domain'); } Config::set('app.url', '://' . $space->host); Config::set('app.sip_domain', $space->domain); if ($request->user() && !$request->user()->superAdmin && $space?->isExpired()) { abort(403, 'The related Space has expired'); } return $next($request); } return abort(404, 'Host not configured'); } }