NuxtN
Nuxt12mo ago
10 replies
heyado

Nuxt, Supabase, Pinia + target="_blank" link = missing data in components

I'm very new to this FE stack, but I've had a problem for days now. I just can't seem to fix it. In a component I have a link like this: <a href="some-other-site" target="_blank">Some xternal site</a>. When I click on the link and then go back to my site's tab, and click on an internal link, some components has stopped working. This is only the case with links that opens a new tab, if I leave _blank out, it's no problem to hit the back button in the browser, it all renders fine. When I get back to my tab I see this in my console:
Auth state changed: SIGNED_IN

That comes from my useAuthStore.js:

// Auth state change listener
auth.onAuthStateChange(async (event, session) => {
console.debug('Auth state changed:', event, 'Session exists:', !!session)

if (event === 'SIGNED_IN' profile.value.id !== verifiedUser.id) {
await fetchProfile(verifiedUser.id)
}
} else if (event === 'SIGNED_OUT') { user.value = null
user.value = null
profile.value = null
isInitialized.value = false
}
})

However, it seems like the data is missing just before the state change or something. I can't figure this out, any ideas? 🫶
Was this page helpful?