back의 미들웨어중 cors에서 credentials: true 를 추가했는지 확인해본다.
credentials: true
없다면 추가해주고 이후 front도 확인한다.
front에서 axios 의 세번째 인자로 withCredentials: true를 넣어줬는지 확인해보자
{ withCredentials: true }
수정후 다시 로그인했는데도 cors에러가 나온다면
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.
back의 cors 미들웨어에 origin 의 주소가 * 로 되어있는지 확인
app.use(
cors({
origin: "*",
credentials: true,
);
이후 정확한 주소로 고쳐준다.
app.use(
cors({
origin: "http://localhost:3000", // ex
credentials: true,
})
);