From 468278349adb71efb8624256afc5690153625fac Mon Sep 17 00:00:00 2001 From: Pontoporeia Date: Mon, 20 Apr 2026 14:13:44 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20router.php=20=E2=80=94=20bypass=20admin?= =?UTF-8?q?=20requests=20to=20front=20controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/router.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/router.php b/app/router.php index a972369..c0e86ab 100644 --- a/app/router.php +++ b/app/router.php @@ -3,7 +3,7 @@ * Router script for PHP built-in development server (php -S). * * All non-asset requests go through the front controller (public/index.php). - * Static files (CSS, JS, images, fonts) are served directly. + * Admin panel and static files are served directly. */ $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); @@ -14,6 +14,19 @@ if (in_array($ext, ['css', 'js', 'png', 'jpg', 'jpeg', 'gif', 'ico', 'svg', 'wof return false; // serve directly } +// Admin panel: serve files directly +if (str_starts_with($uri, '/admin')) { + // Rewrite /admin → /admin/index.php + $file = __DIR__ . '/public' . $uri; + if (is_dir($file)) { + $file .= '/index.php'; + } + if (file_exists($file)) { + include $file; + return true; + } +} + // Send everything else through the front controller $_SERVER['SCRIPT_NAME'] = '/index.php'; require __DIR__ . '/public/index.php';