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. Only once exclusivity is switched on: a machine that lists // its own IP in ADMIN_HOSTS so the console is reachable without DNS // still has to serve the portal from that same address. if (AdminArea::isExclusive() && $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(); // Covers admin.* and the alternate-host registrations (admin.viaN.*), // which are the same console reached by a recovery hostname. return $name !== null && str_starts_with($name, 'admin.'); } }