From 4fd5bf948e4ad8a274d3176d5509163e67980061 Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Mon, 21 Mar 2022 17:49:28 +0500 Subject: [PATCH] fix(cors): removed trailing slashes of urls --- api/src/app.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/src/app.ts b/api/src/app.ts index f898d86..35dfa9b 100644 --- a/api/src/app.ts +++ b/api/src/app.ts @@ -21,10 +21,12 @@ const { MODE, CORS, WHITELIST } = process.env if (MODE?.trim() !== 'server' || CORS?.trim() === 'enable') { const whiteList: string[] = [] WHITELIST?.split(' ')?.forEach((url) => { - if (url.startsWith('http')) whiteList.push(url) + if (url.startsWith('http')) + // removing trailing slash of URLs listing for CORS + whiteList.push(url.replace(/\/$/, '')) }) - console.log('All CORS Requests are enabled') + console.log('All CORS Requests are enabled for:', whiteList) app.use(cors({ credentials: true, origin: whiteList })) }