Skip to content

Commit 556c28b

Browse files
authored
feat(api): Add flag to enable cors (#1757)
1 parent fbeae18 commit 556c28b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ async function bootstrap(): Promise<void> {
4848
]
4949
: defaultOrigins;
5050

51-
app.enableCors({
52-
origin: enabledOrigins,
53-
methods: 'GET, POST, PUT, OPTIONS',
54-
allowedHeaders: ['Content-Type', 'Accept', 'Authorization'],
55-
credentials: true,
56-
});
51+
if (config.get<boolean>('CORS_ENABLED')) {
52+
app.enableCors({
53+
origin: enabledOrigins,
54+
methods: 'GET, POST, PUT, OPTIONS',
55+
allowedHeaders: ['Content-Type', 'Accept', 'Authorization'],
56+
credentials: true,
57+
});
58+
}
5759

5860
app.use(compression());
5961
app.use(helmet());

0 commit comments

Comments
 (0)