update cors

This commit is contained in:
2024-10-13 17:12:33 +07:00
parent 26e4b7c689
commit 263ff4e207
7 changed files with 18 additions and 14 deletions

View File

@@ -4,8 +4,10 @@ import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const corsOrigin = (process.env.CORS_ORIGIN ?? '').split(','); // split by comma to array
app.enableCors({
origin: process.env.CORS_ORIGIN,
origin: corsOrigin,
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true,