CORS error

CHAE·2023년 2월 11일
0

React

목록 보기
22/27

Access to XMLHttpRequest at 'URL' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: 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.

이 에러 메시지는 Cross-Origin Resource Sharing (CORS) 정책에 의해 요청이 차단되었다는 것을 의미합니다. 즉, 클라이언트 (http://localhost:3000)와 API 서버 (API서버 URL) 간에 프로토콜, 도메인, 포트 등의 차이로 인해 API 서버가 클라이언트의 요청을 승인하지 않은 것입니다. 'Access-Control-Allow-Origin' 헤더의 값이 'include'인 요청의 경우 '*'일 수 없다는 것도 언급되어 있습니다. 이 문제를 해결하려면 API 서버 측에서 CORS 정책을 변경하는 것이 좋습니다.

"Access-Control-Allow-Origin": "*", // error 남
"Access-Control-Allow-Origin": true, // error 안남
profile
신입 프론트엔드 개발자

0개의 댓글