'use client'; import { useEffect, useRef } from 'react'; import { clearAuthCookies } from './actions'; import { signOut } from 'next-auth/react'; import Image from 'next/image'; export default function LogoutPage() { const hasStarted = useRef(false); useEffect(() => { if (hasStarted.current) return; hasStarted.current = true; const performLogout = async () => { // Clear localStorage localStorage.setItem('isLoggingOut', 'true'); localStorage.removeItem('accessToken'); localStorage.removeItem('refreshToken'); localStorage.removeItem('user'); await signOut({ redirect: false }); // Delete httpOnly cookies via server action (Next.js cookies() API) await clearAuthCookies(); // Redirect to login immediately window.location.href = '/login'; }; performLogout().catch(() => { window.location.href = '/login'; }); }, []); return (
Signing out...