feat: enable CORS in backoffice with configurable origins
This commit is contained in:
parent
70d89d1c28
commit
64d13581df
2 changed files with 7 additions and 0 deletions
|
|
@ -2,3 +2,4 @@ DATABASE_URL=postgresql://user:password@host:port/dbname?schema=public
|
|||
JWT_SECRET=dev-secret
|
||||
PORT=3000
|
||||
API_URL=http://localhost:3000
|
||||
CORS_ORIGINS=*
|
||||
|
|
|
|||
|
|
@ -13,6 +13,12 @@ async function bootstrap() {
|
|||
);
|
||||
|
||||
const configService = app.get(ConfigService);
|
||||
const corsOrigins = configService.get<string>('CORS_ORIGINS', '*');
|
||||
|
||||
app.enableCors({
|
||||
origin: corsOrigins === '*' ? '*' : corsOrigins.split(','),
|
||||
credentials: true,
|
||||
});
|
||||
|
||||
const cookieOptions: FastifyCookieOptions = {
|
||||
parseOptions: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue