codestates / codestates/BanThing

[Error Handling] 로그아웃을 해도 cookie 가 삭제되지 않는 현상

Open
#170 0 comments 0 reactions 2 assignees Claimed by @minho0513 View on GitHub
client error solved
Dominant language
TypeScript
Stars
0
Forks
2
PR merge metrics
No merged PRs in 30d

Description

### 어떤 에러인가요?
- 로그인을 했을 때 cookie 에 accessToken 이 담기게 되는데,
이후 로그아웃을 해도 cookie 의 accessToken 이 사라지지 않고 남아있었습니다.
```javascript
const handleLogout = () => {
axios
.post(
`${process.env.NEXT_PUBLIC_SERVER_ENDPOINT}/users/logout`,
{},
{
headers: {
Authorization: `Bearer ${prop.accessToken}`,
'Content-Type': 'application/json',
withCredentials: true,
},
},
)}
```

### 에러 핸들링 방법
- withCredentials 가 전달이 되어야하는데, headers 안에 있었기에 제대로 전달되지 않은 것 같습니다.
headers 밖으로 옮겨주니 정상적으로 전달되고, 로그아웃 후 cookie 가 정상적으로 삭제되는 것까지 확인했습니다 :)
```javascript
const handleLogout = () => {
axios
.post(
`${process.env.NEXT_PUBLIC_SERVER_ENDPOINT}/users/logout`,
{},
{
headers: {
Authorization: `Bearer ${prop.accessToken}`,
'Content-Type': 'application/json',
},
withCredentials: true,
},
)}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.