export default defineNuxtPlugin(async () => { const auth = useAuth() const currentPath = useNuxtApp().$router.currentRoute.value.path if ((auth.token.value || auth.tokenState.value) && !auth.user.value) { try { await auth.syncUser({ currentPath }) } catch (error) { const status = (error as any)?.statusCode || (error as any)?.status || (error as any)?.response?.status if (status === 401 || status === 403) { console.error('[Auth Plugin] Sync failed with authentication error, keeping session state:', error) return } console.error('[Auth Plugin] Sync failed:', error) auth.logout() } } })