fix: update CORS middleware to retrieve multiple allowed origins from the database
Deploy Application / deploy (push) Successful in 36s
Details
Deploy Application / deploy (push) Successful in 36s
Details
This commit is contained in:
parent
83ac69ac71
commit
ccccb9d63b
|
|
@ -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,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue