diff --git a/frontend/lib/api.ts b/frontend/lib/api.ts index 5e527635..df0ad6f0 100644 --- a/frontend/lib/api.ts +++ b/frontend/lib/api.ts @@ -27,8 +27,12 @@ const axiosInstance = axios.create({ axiosInstance.interceptors.request.use((config) => { const token = getToken(); + console.log('[API] Request interceptor - token exists:', !!token, 'URL:', config.url); if (token) { config.headers.Authorization = `Bearer ${token}`; + console.log('[API] Authorization header set'); + } else { + console.warn('[API] No token found in localStorage'); } return config; }, (error) => Promise.reject(error)); diff --git a/frontend/lib/auth.ts b/frontend/lib/auth.ts index 18cc4fe3..481b2feb 100644 --- a/frontend/lib/auth.ts +++ b/frontend/lib/auth.ts @@ -24,12 +24,19 @@ export interface AuthUser { * Save JWT token to localStorage */ export const saveToken = (token: AuthToken): void => { + console.log('[Auth] saveToken called with token:', { + access_token: token.access_token?.substring(0, 20) + '...', + user_id: token.user_id, + username: token.username, + role: token.role + }); localStorage.setItem(TOKEN_KEY, token.access_token); localStorage.setItem(USER_KEY, JSON.stringify({ id: token.user_id, username: token.username, role: token.role })); + console.log('[Auth] Token saved to localStorage. TOKEN_KEY:', TOKEN_KEY); }; /**