From bbfdabad2fffc8ed59bb3276a3d179135d0c2ff4 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Sun, 3 May 2026 01:31:38 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20=D9=85=D9=8F=D8=B5=D8=A7=D8=AF?= =?UTF-8?q?=D9=8E=D9=82:=20=D8=AA=D8=AD=D8=AF=D9=8A=D8=AB=20=D8=A8=D8=B1?= =?UTF-8?q?=D9=85=D8=AC=D9=8A=20=D8=AC=D8=AF=D9=8A=D8=AF=202026-05-03=2001?= =?UTF-8?q?:31?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Core/Request.php | 10 +++++++++- public/index.php | 6 ++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/Core/Request.php b/app/Core/Request.php index 49cef51..35d6f91 100644 --- a/app/Core/Request.php +++ b/app/Core/Request.php @@ -18,7 +18,15 @@ final class Request public function __construct() { $this->method = $_SERVER['REQUEST_METHOD']; - $this->path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); + + // Normalize path: extract /api/v1/... portion from any subdirectory structure + $rawPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); + $apiPos = strpos($rawPath, '/api/v1/'); + if ($apiPos !== false) { + $this->path = substr($rawPath, $apiPos); // e.g. /api/v1/auth/login + } else { + $this->path = $rawPath; + } $this->headers = getallheaders(); $this->queryParams = $_GET; $this->files = $_FILES; diff --git a/public/index.php b/public/index.php index 27a6e9e..2747686 100644 --- a/public/index.php +++ b/public/index.php @@ -65,8 +65,10 @@ $router->addRoute('GET', '/api/v1/health', function($request) { }); // ══ SPA Shell ═══════════════════════════════════════════════ -$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); -if (!str_starts_with($path, '/api/v1/')) { +$fullPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); + +// Check if this is an API request (works regardless of subdirectory) +if (!str_contains($fullPath, '/api/v1/')) { include __DIR__ . '/shell.php'; exit; }