From c1402cade50daea68d10e51dcdb325c4e0139305 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 4 Apr 2026 09:57:23 +0100 Subject: [PATCH] refactor: Website/Explorer uses $event->routes() and domain-scoped routing On explorer.lthn.io: routes serve at root (/). On lthn.io: Mod/Explorer handles the /explorer prefix. Adopted CorePHP $event->routes() pattern. Co-Authored-By: Claude Opus 4.6 (1M context) --- app/Website/Explorer/Boot.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/Website/Explorer/Boot.php b/app/Website/Explorer/Boot.php index ad688a5..7b10f77 100644 --- a/app/Website/Explorer/Boot.php +++ b/app/Website/Explorer/Boot.php @@ -13,12 +13,14 @@ use Illuminate\Support\ServiceProvider; /** * Block Explorer website. * - * Serves explorer.lthn.io (prod) or /explorer path on lthn.io. + * On explorer.lthn.io: serves routes at root (/). + * On lthn.io: Mod/Explorer handles /explorer prefix. */ class Boot extends ServiceProvider { public static array $domains = [ '/^explorer\.lthn\.io$/', + '/^explorer\.(test|localhost)$/', ]; public static array $listens = [ @@ -30,8 +32,6 @@ class Boot extends ServiceProvider public function boot(): void { - $this->loadViewsFrom(__DIR__ . '/Views', 'explorer'); - foreach (static::$listens as $event => $method) { Event::listen($event, [$this, $method]); } @@ -47,8 +47,18 @@ class Boot extends ServiceProvider } } - public function onWebRoutes(): void + public function onWebRoutes(WebRoutesRegistering $event): void { - Route::prefix('explorer')->group(__DIR__ . '/Routes/web.php'); + $host = $_SERVER['HTTP_HOST'] ?? ''; + + foreach (static::$domains as $pattern) { + if (preg_match($pattern, $host)) { + // On explorer.lthn.io — serve at root + $event->routes(fn () => Route::group([], __DIR__ . '/Routes/web.php')); + return; + } + } + + // On other domains — no routes (Mod/Explorer handles /explorer prefix) } }