Firebase guest auth has "isAnonymus" property set to false in SSR
greenbeam-ita opened this issue · 2 comments
greenbeam-ita commented
Reproduction
Check snippet below
Steps to reproduce the bug
I'm building my Nuxt 3 App in SSR mode and Firebase auth.
I got an Hydratation issue, don't understand why.
Going trough a deeper inspection detect vuefire do not manage properly firebase guest users.
Simple snippet to in default.vue layout in order to reproduce
<script setup lang="ts">
import { getAuth, sendSignInLinkToEmail, signInWithEmailAndPassword } from 'firebase/auth'
import type { MenuItem } from 'primevue/menuitem'
const currentUser = await getCurrentUser()
console.log('currentUser', currentUser.uid, currentUser.isAnonymous)
nuxt.config.ts vuefire module configuration
vuefire: {
auth: {
enabled: true,
sessionCookie: true,
},
config: {
apiKey: process.env.FIREBASE_API_KEY,
authDomain: process.env.FIREBASE_AUTH_DOMAIN,
projectId: process.env.FIREBASE_PROJECT_ID,
storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.FIREBASE_APP_ID,
},
emulators: false,
},
Expected behavior
I expect to have a proper guest user also in SSR
Actual behavior
From image you can see a mismatch between SSR and client

Additional information
No response
greenbeam-ita commented
I update the issue.
As far as I have session cookie enabled, I check the JWT payload from cookie.
The payload contain correctly the anonymous provider, so in my opinion this is a vuefire bug:
{
"iss": "https://session.firebase.google.com/cloud2local-f018c",
"provider_id": "anonymous",
"aud": "cloud2local-f018c",
"auth_time": 1742745557,
"user_id": "ZjQYBs4bm4dHMF8zH3fQIqo4Q7m1",
"sub": "ZjQYBs4bm4dHMF8zH3fQIqo4Q7m1",
"iat": 1742746590,
"exp": 1743178590,
"firebase": {
"identities": {},
"sign_in_provider": "anonymous"
}
}