diff --git a/frontend/src/api/api.ts b/frontend/src/api/api.ts index c15efef..a9d3399 100644 --- a/frontend/src/api/api.ts +++ b/frontend/src/api/api.ts @@ -31,4 +31,15 @@ api.interceptors.request.use( (error) => Promise.reject(error) ); +// INTERCEPTOR: Global error handling +api.interceptors.response.use( + (response) => response, + (error) => { + if (error.response?.status === 401) { + window.location.href = "/login"; + } + return Promise.reject(error); + } +); + export default api;