Skip to content

Commit 24862be

Browse files
committed
fix: improve token reissue logic with error handling and redirect on failure
1 parent cf4bf90 commit 24862be

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

  • apps/ticket/src/shared/components/AuthErrorFallback

apps/ticket/src/shared/components/AuthErrorFallback/index.tsx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,27 @@ export const AuthErrorFallback = () => {
99

1010
useEffect(() => {
1111
const tokenReissue = async () => {
12-
const res = await fetch("/api/reissue", {
13-
method: "POST",
14-
headers: {
15-
"Content-Type": "application/json",
16-
},
17-
credentials: "include",
18-
});
19-
20-
// 토큰 재발급 후 reload()
21-
window.location.reload();
12+
try {
13+
const res = await fetch("/api/reissue", {
14+
method: "POST",
15+
headers: {
16+
"Content-Type": "application/json",
17+
},
18+
credentials: "include",
19+
});
20+
21+
if (res.ok) {
22+
// 토큰 재발급 성공 → 새로고침
23+
window.location.reload();
24+
} else {
25+
// 재발급 실패 → 로그인
26+
window.location.href = "/login";
27+
}
28+
} catch (error) {
29+
console.error("토큰 재발급 실패:", error);
30+
alert("인증 오류가 발생했습니다. 다시 로그인해주세요.");
31+
window.location.href = "/login";
32+
}
2233
};
2334

2435
tokenReissue();

0 commit comments

Comments
 (0)