fix: simplify cache key handling in CORS middleware
Deploy Application / deploy (push) Successful in 37s Details

This commit is contained in:
faisolavolut 2025-11-11 11:02:22 +07:00
parent a82c732811
commit 83ac69ac71
1 changed files with 2 additions and 11 deletions

View File

@ -56,16 +56,7 @@ app.use((req, res, next) => {
// being present on OPTIONS. To improve reliability we also accept a // being present on OPTIONS. To improve reliability we also accept a
// clientKey via query parameter and fall back to matching the origin // clientKey via query parameter and fall back to matching the origin
// against the `whitelistcors` table below. // against the `whitelistcors` table below.
const clientKey = ( const cacheKey = "__default__";
req.header("x-tenant-key") ||
req.header("X-TENANT-KEY") ||
req.header("X-Tenant-Key") ||
(req.query && (req.query.clientKey || req.query.client_key)) ||
""
)
.toString()
.trim();
const cacheKey = clientKey || "__default__";
(async () => { (async () => {
try { try {
@ -77,7 +68,7 @@ app.use((req, res, next) => {
.filter(Boolean); .filter(Boolean);
const originCors = await db.whitelistcors.findFirst({ const originCors = await db.whitelistcors.findFirst({
where: { origin: origin, is_active: "Y" }, where: { is_active: "Y" },
}); });
if (originCors) { if (originCors) {
allowedOrigins.push(originCors.origin); allowedOrigins.push(originCors.origin);