fix: refactor direct SWR calls to useAuth to prevent 401 loops

This commit is contained in:
dyzulk
2026-01-06 03:11:01 +07:00
parent 3996c4500d
commit 377994c56c
4 changed files with 10 additions and 5 deletions

View File

@@ -44,12 +44,14 @@ import PageLoader from "@/components/ui/PageLoader";
import { useTranslations } from "next-intl";
import { useI18n } from "@/components/providers/I18nProvider";
import { useAuth } from "@/hooks/useAuth";
const fetcher = (url: string) => axios.get(url).then((res) => res.data);
export default function SettingsClient() {
const router = useRouter();
const searchParams = useSearchParams();
const { data: user, mutate: mutateUser } = useSWR("/api/user", fetcher);
const { user, mutate: mutateUser } = useAuth();
const { data: loginHistory, isLoading: historyLoading } = useSWR("/api/profile/login-history", fetcher);
const { data: sessions, isLoading: sessionsLoading } = useSWR("/api/profile/sessions", fetcher);
const { data: apiKeys } = useSWR("/api/api-keys", fetcher);