[allowed_method, module_file] $routes = [ 'v1/auth/login' => ['POST', 'auth/login.php'], 'v1/auth/refresh' => ['POST', 'auth/refresh.php'], 'v1/auth/logout' => ['POST', 'auth/logout.php'], 'v1/users' => ['GET', 'users/index.php'], ]; if (isset($routes[$route])) { [$allowedMethod, $moduleFile] = $routes[$route]; // H1 Fix: Enforce HTTP Method if ($_SERVER['REQUEST_METHOD'] !== $allowedMethod) { header("Allow: {$allowedMethod}"); json_error("Method Not Allowed. Use {$allowedMethod}.", 405); } $file = APP_PATH . '/modules_app/' . $moduleFile; if (file_exists($file)) { require_once $file; } else { json_error("Endpoint file missing: {$route}", 500); } } else { if (str_starts_with($route, 'v1/')) { json_error("Not Found: {$route}", 404); } else { include __DIR__ . '/shell.php'; exit; } }