mirror of
https://github.com/sasjs/server.git
synced 2025-12-10 19:34:34 +00:00
fix(cors): removed trailing slashes of urls
This commit is contained in:
@@ -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 }))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user