fix: Configuration CORS explicite pour dev localhost

This commit is contained in:
MARTIN Julien 2026-01-27 16:36:53 +01:00
parent b3ec1b94ea
commit 264e0d49ae

View File

@ -11,7 +11,14 @@ import { ValidationPipe } from '@nestjs/common';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule, const app = await NestFactory.create(AppModule,
{ logger: ['error', 'warn', 'log', 'debug', 'verbose'] }); { logger: ['error', 'warn', 'log', 'debug', 'verbose'] });
app.enableCors();
// Configuration CORS pour autoriser les requêtes depuis localhost (dev) et production
app.enableCors({
origin: true, // Autorise toutes les origines (dev) - à restreindre en prod
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization', 'Accept'],
credentials: true,
});
app.useGlobalPipes( app.useGlobalPipes(
new ValidationPipe({ new ValidationPipe({