Access to XMLHttpRequest at 'http://localhost/server2026/api/login' from origin 'http://localhost:8100' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status. I was able to fix this in 2024 via API/index.php with
// Add CORS middleware
$app->add(new CorsMiddleware([
"Access-Control-Allow-Origin" => "\*",
"Access-Control-Allow-Headers" => "X-Requested-With, Origin, X-Authorization, Content-Type, Authorization, Accept, Cache-Control, Pragma, Expires",
"Access-Control-Allow-Methods" => "GET, POST, PUT, PATCH, DELETE, OPTIONS",
"Access-Control-Allow-Credentials" => "false"
]));
// Add routing middleware (after CORS middleware so routing is performed first)
$app->addRoutingMiddleware();
// Handle preflight OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
header('Access-Control-Allow-Origin: \*');
header('Access-Control-Allow-Headers: X-Requested-With, Origin, X-Authorization, Content-Type, Authorization, Accept, Cache-Control, Pragma, Expires');
header('Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS');
header('Access-Control-Allow-Credentials: false');
http_response_code(200);
exit();
} but i dont know how to fix this in 2026 . Thank you