From 223b85a714ee41cfc3e49f20dceddf3e273fa117 Mon Sep 17 00:00:00 2001 From: nico Date: Wed, 25 Feb 2026 22:55:36 +0800 Subject: [PATCH] Fix CORS config for staging environment Co-authored-by: Qwen-Coder --- src/app/api/[[...slugs]]/route.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/api/[[...slugs]]/route.ts b/src/app/api/[[...slugs]]/route.ts index 22580aec..d55bb60a 100644 --- a/src/app/api/[[...slugs]]/route.ts +++ b/src/app/api/[[...slugs]]/route.ts @@ -46,11 +46,17 @@ fs.mkdir(UPLOAD_DIR_IMAGE, { }).catch(() => {}); const corsConfig = { - origin: "*", - methods: ["GET", "POST", "PATCH", "DELETE", "PUT"] as HTTPMethod[], - allowedHeaders: "*", + origin: [ + "http://localhost:3000", + "http://localhost:3001", + "https://cld-dkr-desa-darmasaba-stg.wibudev.com", + "https://cld-dkr-staging-desa-darmasaba.wibudev.com", + "*", // Allow all origins in development + ], + methods: ["GET", "POST", "PATCH", "DELETE", "PUT", "OPTIONS"] as HTTPMethod[], + allowedHeaders: ["Content-Type", "Authorization", "*"], exposedHeaders: "*", - maxAge: 5, + maxAge: 86400, // 24 hours credentials: true, };