diff --git a/package.json b/package.json index 851aab1..73f0341 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@nestjs/core": "^11.0.1", "@nestjs/platform-express": "^11.0.1", "@nestjs/sequelize": "^11.0.1", + "cors": "^2.8.6", "mysql2": "^3.16.0", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1", @@ -37,6 +38,7 @@ "@nestjs/cli": "^11.0.0", "@nestjs/schematics": "^11.0.0", "@nestjs/testing": "^11.0.1", + "@types/cors": "^2.8.19", "@types/express": "^5.0.0", "@types/jest": "^30.0.0", "@types/node": "^22.10.7", diff --git a/src/main.ts b/src/main.ts index f76bc8d..3064e9c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,23 @@ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; +import cors from 'cors'; async function bootstrap() { const app = await NestFactory.create(AppModule); + app.use( + cors({ + origin: '*', + methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], + allowedHeaders: [ + 'Content-Type', + 'Authorization', + 'X-Requested-With', + 'Accept', + 'Origin', + 'authClientToken', + ], + }), + ); await app.listen(process.env.PORT ?? 3000); } bootstrap();