Value is missing on SSR
Can you please clarify why I can't get loggedIn.value on SSR is this intended behaviour?
here is how my code looks like:
const { $auth } = useNuxtApp()
const { user, loggedIn } = $auth
if (import.meta.server) {
console.log(`🆘 ~ SERVER loggedIn:`, loggedIn)
console.log(`🆘 ~ SERVER loggedIn:`, loggedIn.value)
}
if (import.meta.client) {
console.log(`🆘 ~ CLIENT loggedIn:`, loggedIn)
console.log(`🆘 ~ CLIENT loggedIn:`, loggedIn.value)
}
And here is the result:
SSR:
CLIENT:
@paulvonber Can you create a reproduce repo on codesandbox or stackblitz? It seem something's wrong with your code, I'm testing on local but the SSR works just fine.
The component
The debug log on server side
The SSR content
@trandaison I'll try to find a time to create repro as this is a bit of things to do. But would you try out to get the value within the middleware as I have problem there in the page/component everything works correctly for me as well.
@paulvonber The same result.
Did you set auth.middleware.global = false in the nuxt.config.ts file?
I do have auth.middleware.global = true not sure if that anyhow clashes, but I also try to use it in middleware_name.global.js so globally as well.
I got it. Your middleware is a global one, and it has a higher order than the auth middleware, so it executes before the auth middleware where I put the logic to determine the login session.
I will fix in the next release. Thanks for the support!
@paulvonber This issue is related to an nuxt issue here: https://github.com/nuxt/nuxt/issues/27932 It was fixed however it will be release in the next major version (v4.0.0), after v4 is released, this issue will be fix on nuxt-3-auth.