'use client'; import { useEffect, useRef } from 'react'; import { signOut } from 'next-auth/react'; export default function LogoutPage() { const hasStarted = useRef(false); useEffect(() => { if (hasStarted.current) return; hasStarted.current = true; // Set logout flag to prevent TokenSync/PresenceProvider from restoring tokens localStorage.setItem('isLoggingOut', 'true'); // Clear all localStorage auth data localStorage.removeItem('accessToken'); localStorage.removeItem('refreshToken'); localStorage.removeItem('user'); // Use signOut with callbackUrl - this ensures the server clears the // session cookie BEFORE the redirect happens (server-side 302). // Do NOT use redirect:false + manual redirect, as that causes a race // condition where navigation happens before the cookie is cleared. signOut({ callbackUrl: '/login' }); }, []); return (
Please wait while we securely log you out...