feat(api): custom cors settings

This commit is contained in:
Daniel Hougaard
2025-01-10 22:23:19 +01:00
parent d7ffa70906
commit ccb07942de
3 changed files with 56 additions and 3 deletions
+10 -1
View File
@@ -87,7 +87,16 @@ export const main = async ({ db, hsmModule, auditLogDb, smtp, logger, queue, key
await server.register<FastifyCorsOptions>(cors, {
credentials: true,
origin: appCfg.SITE_URL || true
...(appCfg.CORS_ALLOWED_ORIGINS?.length
? {
origin: appCfg.CORS_ALLOWED_ORIGINS
}
: {
origin: appCfg.SITE_URL || true
}),
...(appCfg.CORS_ALLOWED_HEADERS?.length && {
allowedHeaders: appCfg.CORS_ALLOWED_HEADERS
})
});
await server.register(addErrorsToResponseSchemas);