Skip to content

Commit

Permalink
Added corsdebug to requests
Browse files Browse the repository at this point in the history
  • Loading branch information
JacoKoster authored and tkurki committed Sep 9, 2023
1 parent 8d92ac3 commit 6b2d0a2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down

0 comments on commit 6b2d0a2

Please sign in to comment.