CORS 정책 제한 ERROR

TaeWoo·2023년 12월 4일

nodejs

목록 보기
1/12
post-thumbnail

Access to XMLHttpRequest at 'http://localhost:3000/api/stations' from origin 'http://localhost:3090' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

이 에러는 CORS(Cross-Origin Resource Sharing) 정책 제한으로 인해 발생합니다. CORS는 웹 브라우저에서 웹 페이지가 해당 웹 페이지를 제공한 도메인과 다른 도메인으로의 요청을 막기 위한 보안 기능입니다.서버가 CORS 정책을 올바르게 구성하지 않았기 때문에 발생하는 것입니다.

해결방법

app.use(
  cors({
    origin: true, 
    credentials: true,
  })
);
profile
코드와 아이디어의 소통, 기록하는 개발자. 🚀✨

0개의 댓글