인프런 커뮤니티 질문&답변
로그아웃 요청이 403 forbidden 에러가 나는데 왜그런걸까요??
작성
·
403
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 와함꼐 보내고있습니다.






넵 쿠키가 브라우저에 심어졌습니다.
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 이런에러가뜨네요 로그아웃하려고할때마다