diff --git a/public/index.php b/public/index.php index 59586c2..05810f2 100644 --- a/public/index.php +++ b/public/index.php @@ -6,6 +6,7 @@ require __DIR__ . '/../vendor/autoload.php'; use App\Bootstrap\AppBootstrap; use App\Config\AppConfig; +use App\Middleware\CorsMiddleware; use App\Modules\Auth\AuthRoutes; use App\Modules\Health\HealthRoutes; use App\Modules\Retribusi\Dashboard\DashboardRoutes; @@ -19,6 +20,9 @@ AppConfig::loadEnv(__DIR__ . '/..'); // Bootstrap application $app = AppBootstrap::create(); +// ✅ REGISTER CORS MIDDLEWARE GLOBAL (PALING ATAS) +$app->add(new CorsMiddleware()); + // Global OPTIONS route for CORS preflight (must be before other routes) $app->options('/{routes:.+}', function ($request, $response) { return $response->withStatus(204);