"use client"; import { useEffect, useRef } from "react"; import { useSearchParams, useRouter } from "next/navigation"; export default function AuthCallbackClient() { const params = useSearchParams(); const router = useRouter(); const ran = useRef(false); useEffect(() => { if (ran.current) return; ran.current = true; const token = params.get("token"); if (!token) { router.replace("/login"); return; } fetch("/api/auth/callback", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ token }), }) .then(async (res) => { if (!res.ok) throw new Error(await res.text()); router.replace("/app"); }) .catch(() => { router.replace("/login"); }); }, [params, router]); return (
Please wait while we authenticate your account
{/* Progress indication */}