fix: Register CORS middleware di public/index.php sebelum semua route
This commit is contained in:
@@ -6,6 +6,7 @@ require __DIR__ . '/../vendor/autoload.php';
|
|||||||
|
|
||||||
use App\Bootstrap\AppBootstrap;
|
use App\Bootstrap\AppBootstrap;
|
||||||
use App\Config\AppConfig;
|
use App\Config\AppConfig;
|
||||||
|
use App\Middleware\CorsMiddleware;
|
||||||
use App\Modules\Auth\AuthRoutes;
|
use App\Modules\Auth\AuthRoutes;
|
||||||
use App\Modules\Health\HealthRoutes;
|
use App\Modules\Health\HealthRoutes;
|
||||||
use App\Modules\Retribusi\Dashboard\DashboardRoutes;
|
use App\Modules\Retribusi\Dashboard\DashboardRoutes;
|
||||||
@@ -19,6 +20,9 @@ AppConfig::loadEnv(__DIR__ . '/..');
|
|||||||
// Bootstrap application
|
// Bootstrap application
|
||||||
$app = AppBootstrap::create();
|
$app = AppBootstrap::create();
|
||||||
|
|
||||||
|
// ✅ REGISTER CORS MIDDLEWARE GLOBAL (PALING ATAS)
|
||||||
|
$app->add(new CorsMiddleware());
|
||||||
|
|
||||||
// Global OPTIONS route for CORS preflight (must be before other routes)
|
// Global OPTIONS route for CORS preflight (must be before other routes)
|
||||||
$app->options('/{routes:.+}', function ($request, $response) {
|
$app->options('/{routes:.+}', function ($request, $response) {
|
||||||
return $response->withStatus(204);
|
return $response->withStatus(204);
|
||||||
|
|||||||
Reference in New Issue
Block a user