From ccccb9d63b40326c5df168a1c9b47ba0b0d19da5 Mon Sep 17 00:00:00 2001 From: faisolavolut Date: Tue, 11 Nov 2025 11:03:37 +0700 Subject: [PATCH] fix: update CORS middleware to retrieve multiple allowed origins from the database --- src/app.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app.ts b/src/app.ts index 62a27de..9e89e8a 100644 --- a/src/app.ts +++ b/src/app.ts @@ -67,11 +67,11 @@ app.use((req, res, next) => { .map((s) => s.trim()) .filter(Boolean); - const originCors = await db.whitelistcors.findFirst({ + const originCors = await db.whitelistcors.findMany({ where: { is_active: "Y" }, }); - if (originCors) { - allowedOrigins.push(originCors.origin); + if (originCors.length > 0) { + allowedOrigins.push(...originCors.map((item) => item.origin)); } corsCache.set(cacheKey, { origins: allowedOrigins,