본문 바로가기
Q&A해결2026년 8월 3일2분 읽기

credentials 포함 요청인데 쿠키가 안 실리고 CORS에서 막힙니다

c
cors_minje
조회 834댓글 2

프론트는 app.example.com, API는 api.example.com으로 도메인이 분리돼 있고요. 로그인하면 서버가 세션 쿠키를 내려주는데, 이후 요청에 그 쿠키가 안 실려서 계속 401이 납니다. fetch에 credentials: 'include'는 넣었어요.

그리고 콘솔엔 이 에러가 뜹니다.

Access to fetch at 'https://api.example.com/me' from origin 'https://app.example.com' 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'.

서버 쪽 CORS는 편하게 Access-Control-Allow-Origin: *로 열어놨었는데, 이거랑 관련이 있어 보이긴 합니다. 프론트에서 credentials만 넣으면 될 줄 알았는데 뭘 더 맞춰야 하나요?

댓글 0

아직 댓글이 없습니다.
Ctrl+Enter로 등록