fix: Reorder CORS middleware to execute after RoutingMiddleware (LIFO)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user