fix: update CORS middleware to retrieve multiple allowed origins from the database
Deploy Application / deploy (push) Successful in 36s Details

This commit is contained in:
faisolavolut 2025-11-11 11:03:37 +07:00
parent 83ac69ac71
commit ccccb9d63b
1 changed files with 3 additions and 3 deletions

View File

@ -67,11 +67,11 @@ app.use((req, res, next) => {
.map((s) => s.trim()) .map((s) => s.trim())
.filter(Boolean); .filter(Boolean);
const originCors = await db.whitelistcors.findFirst({ const originCors = await db.whitelistcors.findMany({
where: { is_active: "Y" }, where: { is_active: "Y" },
}); });
if (originCors) { if (originCors.length > 0) {
allowedOrigins.push(originCors.origin); allowedOrigins.push(...originCors.map((item) => item.origin));
} }
corsCache.set(cacheKey, { corsCache.set(cacheKey, {
origins: allowedOrigins, origins: allowedOrigins,