본문 바로가기
개발 프레임워크/NestJS

[NestJS] NestJS에서 cors error 해결

by minhyeok.lee 2023. 11. 13.
반응형

src/main.ts에서 아래 코드 내용을 추가한다.

 

import { NestFactory } from '@nestjs/core';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  ...
  
  app.enableCors({
    origin: [
      "http://[client 주소 (frontend 주소)]",
    ],
    credentials: true,
  });

  ...
  
}
bootstrap();
반응형

댓글