isConsoleRoute($request); $onConsoleHost = AdminArea::covers($request->getHost()); // The console, reached through a hostname that is not the console's. if ($isConsoleRoute && ! $onConsoleHost) { abort(404); } // The portal or the public site, reached through the console's hostname. if ($onConsoleHost && ! $isConsoleRoute && ! $request->is(...self::SHARED)) { abort(404); } return $next($request); } /** * Console routes are the ones named `admin.*`. * * By name rather than by path: the path is exactly what changes between * host-bound and fallback mode, and a rule written against it would be * wrong in one of them. */ private function isConsoleRoute(Request $request): bool { $name = $request->route()?->getName(); return $name !== null && str_starts_with($name, 'admin.'); } }