page.tsx:150 PUT https://mizizzi-ecommerce-1.onrender.com/api/theme/admin/themes/2 401 (Unauthorized)
intercept-console-error.ts:42 [v0] Save theme failed: 401
{code: 'token_expired', error: 'Token has expired'}
intercept-console-error.ts:42 [v0] Error saving theme: Error: Failed to save theme (401) at saveTheme (page.tsx:172:15)
I see the dev server is still crashing due to the workspaces field in the v0-next-shadcn package.json. The actual issue is the auth token is expired (401). Let me fix both issues:
Let me first check which package.json needs fixing:
Good, that one looks correct. Now let me check if there's a frontend package.json with workspaces:
Good, frontend package.json looks fine. Now let me focus on the real issue: the token is expired (401 error). I need to implement token refresh logic in the theme save function. Let me check the auth utilities:
Let me check the auth utilities to understand how tokens are managed:
I can see there's already a refreshAccessToken method in the auth service. Now let me check the theme page and add token refresh logic when a 401 error occurs:
Now I need to update the saveTheme function to handle 401 errors by attempting to refresh the token and retrying. Let me add this logic:
Now update the saveTheme function to handle 401 errors with token refresh:
Also update the fetchActiveTheme function to handle 401 with token refresh:
I've implemented automatic token refresh for the theme save and fetch operations. Here's what I added:
Key changes:
refreshAccessToken methodfetchActiveTheme and saveTheme now handle expired tokens gracefullyWhen you try to save now and get a 401 error, the app will automatically attempt to refresh your authentication token and retry the save without requiring you to manually log back in. If token refresh fails, it will show a clear error message asking you to log in again.
v55 was created by restoring v53
You can send messages while the preview loads