[nestJs] CORS 관련 모음

Edward Hyun·2022년 4월 21일
0

backend

목록 보기
65/120

서버에서 response를 보낼 때
header에 "Access-Control-Allow-Origin" = * 을 추가한다.

NestJs에서는 다음 둘 중 하나를 추가하면 된다.

// main.ts
const app = await NestFactory.create(AppModule);
app.enableCors();
await app.listen(3000);
const app = await NestFactory.create(AppModule, { cors: true });
await app.listen(3000);

출처 ::
[1] 내가 찾은 CORS Error의 올바른 해결법
https://coding-groot.tistory.com/91
[2]
https://velog.io/@suasue/NestJS-CORS-%EC%84%A4%EC%A0%95
[3] https://github.com/expressjs/cors#configuration-options
[4]
https://donggoolosori.github.io/2021/03/01/nest-cors/
[5] https://kangaroo-dev.tistory.com/8

profile
앱&웹개발(flutter, vuejs, typescript, react), 인공지능(nlp, asr, rl), 백엔드(nodejs, flask, golang, grpc, webrtc, aws, msa, nft, spring cloud, nest.js), 함수형 프로그래밍(scala, erlang)을 공부하며 정리합니다.

0개의 댓글