We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f46a1c8 commit 06674fdCopy full SHA for 06674fd
1 file changed
src/runtime/plugins/supabase.client.ts
@@ -44,6 +44,16 @@ export default defineNuxtPlugin({
44
const currentSession = useSupabaseSession()
45
const currentUser = useSupabaseUser()
46
47
+ // In SPA mode, restore session from storage before auth middleware runs.
48
+ // This prevents a race condition where middleware checks session before it's hydrated.
49
+ // See: https://github.com/nuxt-modules/supabase/issues/496
50
+ if (!useSsrCookies) {
51
+ const { data } = await client.auth.getSession()
52
+ if (data.session) {
53
+ currentSession.value = data.session
54
+ }
55
56
+
57
// Populate user before each page load to ensure the user state is correctly set before the page is rendered
58
nuxtApp.hook('page:start', async () => {
59
const { data } = await client.auth.getClaims()
0 commit comments