diff --git a/frontend/src/config/api.ts b/frontend/src/config/api.ts index 39572af..724d63f 100644 --- a/frontend/src/config/api.ts +++ b/frontend/src/config/api.ts @@ -82,13 +82,13 @@ api.interceptors.response.use( } } - if (error.response?.status === 401) { + if (error.response?.status === 401 || error.response?.status === 403) { // Check if it's an admin route const isAdminRoute = error.config?.url?.includes('/admin'); const currentPath = window.location.pathname; if (isAdminRoute) { - // Clear admin token on unauthorized + // Clear admin token on unauthorized or forbidden Cookies.remove(ADMIN_TOKEN_KEY); // Only redirect if we're not already on the admin login page if (!currentPath.includes('/admin/login')) { diff --git a/frontend/src/pages/admin/AnalyticsPage.tsx b/frontend/src/pages/admin/AnalyticsPage.tsx index be7993b..c883d8b 100644 --- a/frontend/src/pages/admin/AnalyticsPage.tsx +++ b/frontend/src/pages/admin/AnalyticsPage.tsx @@ -76,6 +76,11 @@ export const AnalyticsPage: React.FC = () => { const fetchUmamiConfig = async () => { try { const response = await fetch(`${import.meta.env.VITE_API_URL}/api/public/settings`); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + const settings = await response.json(); // Check if Umami is enabled in admin settings