프론트(app.example.com)에서 API(api.example.com)를 쿠키 인증으로 호출하는데 계속 막힙니다.
Access to fetch ... 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'.
서버에 Access-Control-Allow-Origin: *와 credentials: true를 같이 줬는데도 안 됩니다. 쿠키도 요청에 안 실리는 것 같고요.
댓글 4
두 가지가 동시에 걸렸습니다.
1) 와일드카드 + credentials 동시 사용 불가 — 에러 메시지 그대로입니다.
credentials: 'include'면 서버는*가 아니라 정확한 출처를 돌려줘야 하고,Access-Control-Allow-Credentials: true도 함께 줘야 합니다.2) 프론트도 credentials 명시 + 쿠키 속성
교차 사이트로 쿠키가 실리려면 쿠키에
SameSite=None; Secure가 필요합니다(HTTPS 필수). 서브도메인 공유면Domain=.example.com도 고려하세요.3) 프리플라이트(OPTIONS)에도 200과 허용 헤더(Allow-Methods/Headers)를 반드시 응답해야 합니다. 커스텀 헤더(Authorization 등)를 쓰면
Access-Control-Allow-Headers에 포함시켜야 통과합니다.맞습니다.
Secure쿠키는 HTTPS에서만 전송됩니다. 로컬은 ① https 개발 서버를 쓰거나 ② 같은 출처로 프록시(dev 서버 proxy)해서 교차 사이트 자체를 없애는 방법이 깔끔합니다. 운영은 그대로 SameSite=None; Secure 유지하세요.