fix cors
Deploy / deploy (push) Successful in 34s

This commit is contained in:
Rayyan
2026-08-03 20:32:17 +07:00
parent 1826bc789e
commit 470396c2f1
3 changed files with 43 additions and 7 deletions
+19 -1
View File
@@ -20,7 +20,25 @@ async function bootstrap() {
}),
);
app.enableCors();
// CORS configuration: only allow configured frontend origins and enable credentials
const allowedOrigins: string[] = [];
const frontend = config.get<string>('FRONTEND_URL');
const prodFrontend = config.get<string>('PRODUCTION_FRONTEND_URL');
if (frontend) allowedOrigins.push(frontend);
if (prodFrontend) allowedOrigins.push(prodFrontend);
app.enableCors({
origin: allowedOrigins,
credentials: true,
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
allowedHeaders: [
'Content-Type',
'Authorization',
'Accept',
'Origin',
'X-Requested-With',
],
});
const swaggerEnabled = config.get<string>('SWAGGER_ENABLED') === 'true';