feat: enable CORS in backoffice with configurable origins

This commit is contained in:
Tiago Yamamoto 2025-12-27 00:42:57 -03:00
parent 70d89d1c28
commit 64d13581df
2 changed files with 7 additions and 0 deletions

View file

@ -2,3 +2,4 @@ DATABASE_URL=postgresql://user:password@host:port/dbname?schema=public
JWT_SECRET=dev-secret JWT_SECRET=dev-secret
PORT=3000 PORT=3000
API_URL=http://localhost:3000 API_URL=http://localhost:3000
CORS_ORIGINS=*

View file

@ -13,6 +13,12 @@ async function bootstrap() {
); );
const configService = app.get(ConfigService); const configService = app.get(ConfigService);
const corsOrigins = configService.get<string>('CORS_ORIGINS', '*');
app.enableCors({
origin: corsOrigins === '*' ? '*' : corsOrigins.split(','),
credentials: true,
});
const cookieOptions: FastifyCookieOptions = { const cookieOptions: FastifyCookieOptions = {
parseOptions: { parseOptions: {