24.06.22 21:26 작성
·
185
0
"success": false,
"code": 403,
"data": "Forbidden resource"
이렇게 에러가납니다.
@ApiCookieAuth('connect.sid')
@UseGuards(LoggedInGuard)
@Post('logout')
async logout(@Res() res) {
console.log(res);
res.clearCookie('connect.sid', { httpOnly: true });
return res.send('ok');
}
프론트에서는
const logoutMutation = useMutation({
mutationFn: () => {
return api.post("/api/teachers/logout");
},
onSuccess: (res) => {
localStorage.removeItem("teacherState");
router.push("/auth/login");
},
onError: (error) => {
console.log(error);
},
});
이런식으로 보내고있거든요 api는 axios에 credentials: true 와함꼐 보내고있습니다.
답변 1
0
2024. 06. 23. 00:19
저건 지금 로그인을 안 한 상태에서 로그아웃 요청을 했다는 뜻입니다. api가 axios instance인 건가요? 일단 withCredentials와 상관 없이 로그인 후 쿠키가 브라우저에 심어졌는지 궁금하네요. 로그아웃 말고도 다른 api 요청도 403 뜨지 않나요?
2024. 06. 23. 17:26
Connection is not established with mysql database
에러메시지를 보면 지금 무언가때문에 DB와의 연결이 끊기는 것 같은데요. 그게 원인이 아닐까 싶습니다.
2024. 06. 23. 15:13
넵 쿠키가 브라우저에 심어졌습니다.
api는 axios 인스턴스가맞습니다.
그리고 보면 브라우저에 쿠키가심어집니다. 그리고 처음에 로그인후 가입하면 정상적으로 로그인 /로그아웃이 되는걸 확인했는데요. 일정시간이지나면 로그아웃이안되는데 왜그런지 잘모르겠네요...
세션설정은 아래와같이 설정했습니다.
확인해보면 nestjs를 끄지않고 나두면 아래에러가발생합니다. 그래서 다시 서버를 재시작하면 로그인 로그아웃이 정상적으로 되는걸확인했습니다. 그러나 일정시간이 지나면 다시 저에러가 나타나더라구요. 왜그런지 잘모르겠네요
[Nest] 18712 - 2024. 06. 23. 오후 3:14:56 ERROR [ExceptionsHandler] Connection is not established with mysql database
TypeORMError: Connection is not established with mysql database 이런에러가뜨네요 로그아웃하려고할때마다