Other
withCredentials 옵션
hyebin Lee
2022. 7. 30. 22:28
프론트 서버와 백엔드 서버의 도메인이 다를 경우 백엔드에서 프론트엔드로 쿠키를 생성시켜 줄 수 없고, 프론트에서 백엔드로 쿠키를 보낼 수 도 없다. 이 문제를 해결 하기 위해 withCredentials : true 로 설정한다.
axios.post(`${EndPoint.APIServer}/login/`, {
profile: { username: username, password: password }
}, {
withCredentials: true // 쿠키 cors 통신 설정
})
.then(response => {
console.log(response);
console.log(response.data);
})