diff --git a/src/Bootstrap/app.php b/src/Bootstrap/app.php index 4e55a97..d521724 100644 --- a/src/Bootstrap/app.php +++ b/src/Bootstrap/app.php @@ -23,6 +23,10 @@ class AppBootstrap { $app = AppFactory::create(); + // Add CORS middleware FIRST (will execute AFTER routing due to LIFO) + // This ensures CORS headers are added to all responses, including OPTIONS preflight + $app->add(new CorsMiddleware()); + // Add body parsing middleware $app->addBodyParsingMiddleware(); @@ -56,10 +60,6 @@ class AppBootstrap }); }); - // Add CORS middleware LAST (after error middleware) - // This ensures CORS headers are added to all responses, including errors - $app->add(new CorsMiddleware()); - return $app; } }