feat: JWT 만료/로그아웃 시 자동 리다이렉트 처리
All checks were successful
Client CI/CD / deploy (push) Successful in 11s

- 401 응답 시 auth:unauthorized 이벤트 발생 (client.js)
- AuthContext에서 이벤트 수신 시 자동 로그아웃
- 관리자 페이지에서 인증 만료 시 메인으로, 그 외는 로그인 페이지로 이동

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-24 16:38:46 +09:00
parent 2ac2823ecc
commit e025fdfe87
3 changed files with 47 additions and 15 deletions

View File

@@ -6,6 +6,9 @@ export async function apiFetch(path, options = {}) {
if (token) headers['Authorization'] = `Bearer ${token}`;
const res = await fetch(BASE + path, { ...options, headers });
if (res.status === 401) {
window.dispatchEvent(new Event('auth:unauthorized'));
}
if (!res.ok) {
const err = new Error(res.statusText);
err.status = res.status;