Fix jwt-token
This commit is contained in:
@@ -46,12 +46,10 @@ api.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
if (error.response?.status === 401) {
|
||||
// Token expired or invalid - let AuthContext handle this
|
||||
// Token expired or invalid - remove token and let ProtectedRoute handle navigation
|
||||
localStorage.removeItem('token');
|
||||
// Only redirect if not already on login page
|
||||
if (window.location.pathname !== '/login') {
|
||||
window.location.href = '/login';
|
||||
}
|
||||
// Force a state update by dispatching a custom event
|
||||
window.dispatchEvent(new CustomEvent('auth-logout'));
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user