export default defineNuxtPlugin((nuxtApp) => {
    const { data, signOut } = useAuth();

    // Watch for session changes
    watch(data, async (session) => {
        if (session?.error === 'RefreshAccessTokenError') {
            console.warn('Refresh token expired or invalid. Signing out...');
            await signOut({ callbackUrl: '/auth/login' });
        }
    }, { immediate: true });
});
