From 6b2d0a2293626d02f96e23381617f1bf2859e8cd Mon Sep 17 00:00:00 2001 From: Jaco Koster Date: Fri, 8 Sep 2023 17:30:00 +0200 Subject: [PATCH] Added corsdebug to requests --- src/cors.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cors.ts b/src/cors.ts index 587e4df92..8d8e3859f 100644 --- a/src/cors.ts +++ b/src/cors.ts @@ -17,10 +17,21 @@ export function setupCors( corsDebug(`corsOrigins:${corsOrigins.toString()}`) const corsOptions: CorsOptions = { credentials: true, - origin: allowedCorsOrigins + origin: corsOrigins } app.use(cors(corsOptions)) + app.use((req, res, next) => { + const origin = req.header('origin') + if (origin !== undefined && !corsOrigins.includes(origin)) { + corsDebug( + `${origin} is not present in corsOrigins: ${corsOrigins.toString()}` + ) + } else { + corsDebug(`${origin} is allowed`) + } + next() + }) } export const handleAdminUICORSOrigin = (