Fixing comments from PR

This commit is contained in:
automaton82
2024-01-25 15:29:02 -05:00
parent 3be2393412
commit 657dace89e
7 changed files with 32 additions and 26 deletions
+16 -2
View File
@@ -24,8 +24,22 @@ export function getAllowedCorsOrigins(): string {
return process.env.CORS_ORIGINS ?? '*'
}
export function getAllowedEmbeddingOrigins(): string {
export function getCorsOptions(): any {
const corsOptions = {
origin: function (origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) {
const allowedOrigins = getAllowedCorsOrigins()
if (!origin || allowedOrigins == '*' || allowedOrigins.indexOf(origin) !== -1) {
callback(null, true)
} else {
callback(new Error('Not allowed by CORS'))
}
}
}
return corsOptions
}
export function getAllowedIframeOrigins(): string {
// Expects FQDN separated by commas, otherwise nothing or * for all.
// Also CSP allowed values: self or none
return process.env.EMBEDDING_ORIGINS ?? '*'
return process.env.IFRAME_ORIGINS ?? '*'
}