fix: redirect to login on expired/missing JWT and 401 responses

This commit is contained in:
2026-04-13 08:17:57 -04:00
parent 435c004760
commit ac094965b5
2 changed files with 31 additions and 5 deletions

View File

@@ -12,4 +12,15 @@ api.interceptors.request.use((config) => {
return config;
});
api.interceptors.response.use(
(response) => response,
(error) => {
if (error.response?.status === 401) {
localStorage.removeItem('token');
window.dispatchEvent(new Event('auth:logout'));
}
return Promise.reject(error);
}
);
export default api;