Nest.js CORS の設定

updated Oct 1, 2021created Oct 2, 2021
js
import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import { ConfigService } from '@nestjs/config'; async function bootstrap() { const app = await NestFactory.create(AppModule); const configService = app.get(ConfigService); app.enableCors({ origin: '*', allowedHeaders: 'Origin, X-Requested-With, Content-Type, Accept', }); // or // app.enableCors(); await app.listen(configService.get('port')); } bootstrap();

CORS | NestJS - A progressive Node.js framework