From d579db60959f021efa121edc135ab1b7ed7fb322 Mon Sep 17 00:00:00 2001 From: RikThePixel Date: Wed, 10 Jan 2024 20:03:18 +0100 Subject: [PATCH] Trim origins --- apps/gateway/src/middleware/cors.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/gateway/src/middleware/cors.ts b/apps/gateway/src/middleware/cors.ts index a80326f..de42666 100644 --- a/apps/gateway/src/middleware/cors.ts +++ b/apps/gateway/src/middleware/cors.ts @@ -6,9 +6,9 @@ export interface CorsOptions extends Omit { const cors = ({ origin, ...opts }: CorsOptions = {}) => { const whitelistedOrigins = Array.isArray(origin) - ? (origin.filter((org) => Boolean(org)) as string[]) + ? (origin.filter((org) => Boolean(org)) as string[]).map((org) => org.trim()) : typeof origin === 'string' - ? [origin] + ? [origin.trim()] : undefined; return makeCors({ @@ -16,7 +16,7 @@ const cors = ({ origin, ...opts }: CorsOptions = {}) => { const verdict = whitelistedOrigins && reqOrigin && - whitelistedOrigins.includes(reqOrigin); + whitelistedOrigins.includes(reqOrigin.trim()); callback(null, verdict); },