-
-
Notifications
You must be signed in to change notification settings - Fork 19
Session are not available on server side rendering #57
Comments
i have this proboeml too, it's not working in server request. like the counter demo ,if use |
Same issue, session is null in server side!!! In client has value!! |
The composable for https://github.com/sidebase/nuxt-session/blob/main/src/runtime/composables/useSession.ts Without testing this library, I wonder how necessary this is. We've found that I don't know enough about this though and the official Nuxt documentation around this situation is a bit ambiguous. But I have tested this in local dev, logging in with a user, then disabling JavaScript on the site via Chrome; the current user's email appears in one SSR-renderable part of the screen without fail. In our case we were using a plain const { data, error, refresh, pending } = await useFetch('/api/auth/user', { method: 'GET' }) Back to this library, it's interesting that this comment was left there: // Do not fetch on server, as the cookie is stored and sent by the client
server: false, And you can see in @mlutsiuk's pull request (#73) that they're forwarding the cookies but still have that flag disabled. I suspect it might have something to do with the way caching is handled but I don't have enough in-depth knowledge. |
Any notice??? |
related #83 |
Environment
Reproduction
https://stackblitz.com/edit/github-e43zzb?file=app.vue
If you type something in the input and refresh the page, the server will not know about the session that was updated, thus preventing doing server side rendering without node mismatch.
Describe the bug
I'd like to access my sessions in my root
app.vue
file :If I run this code, it works well on client side. However on server side the value of the session is always empty.
Can I access the data on server side so I can do proper server side rendering ?
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: