From bae1da324bb682a9929b6df41eb99493f816b64e Mon Sep 17 00:00:00 2001 From: mwpn Date: Wed, 17 Dec 2025 14:02:49 +0700 Subject: [PATCH] fix: Perbaiki CORS middleware agar selalu add headers jika wildcard diizinkan, tambah script check_cors.php --- bin/check_cors.php | 78 +++++++++++++++++++++++++++++++ src/Middleware/CorsMiddleware.php | 6 +++ 2 files changed, 84 insertions(+) create mode 100644 bin/check_cors.php diff --git a/bin/check_cors.php b/bin/check_cors.php new file mode 100644 index 0000000..42ceba7 --- /dev/null +++ b/bin/check_cors.php @@ -0,0 +1,78 @@ +getAllowedOrigin($origin); + // Always add CORS headers if wildcard is allowed (even if origin is empty) + // This ensures CORS works for all requests + if ($allowedOrigin === null && in_array('*', $this->allowedOrigins, true)) { + $allowedOrigin = '*'; + } + if ($allowedOrigin) { $response = $response->withHeader('Access-Control-Allow-Origin', $allowedOrigin); }