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); },