diff --git a/src/hooks/usePrompts.ts b/src/hooks/usePrompts.ts index cb26485..10f1180 100644 --- a/src/hooks/usePrompts.ts +++ b/src/hooks/usePrompts.ts @@ -2,6 +2,7 @@ import { useEffect, useCallback, useRef } from "react"; import { useStore } from "@/store/promptStore"; import { fetchGalleryPrompts, fetchUserPrompts } from "@/api/prompts"; import type { Prompt } from "../types"; +import { AxiosError } from "axios"; export type PromptType = "user" | "gallery" | null; @@ -42,8 +43,11 @@ const usePrompts = (promptId?: number): UsePromptsResult => { addUserPrompts(prompts); } return true; - } catch (error) { + } catch (error: unknown) { console.error(`Error fetching ${isGallery ? "gallery" : "user"} prompts:`, error); + if ((error as AxiosError).response?.status === 401) { + window.location.href = "https://www.astria.ai/users/sign_in"; + } return false; } }, [galleryOffset, userOffset, limit, addGalleryPrompts, addUserPrompts]); diff --git a/src/services/apiClient.ts b/src/services/apiClient.ts index 01c2500..a8c9c81 100644 --- a/src/services/apiClient.ts +++ b/src/services/apiClient.ts @@ -58,14 +58,8 @@ export const post = async (url: string, data: object): Promise const handleApiError = (error: AxiosError): void => { if (error.response?.status === 401) { - window.location.href = 'https://astria.ai/login'; + window.location.href = 'https://www.astria.ai/users/sign_in'; return; - } else if (error.response) { - console.error('API Error:', error.response.status, error.response.data); - } else if (error.request) { - console.error('No response received:', error.request); - } else { - console.error('Error:', error.message); } };