Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase guest auth has "isAnonymus" property set to false in SSR #1613

Open
greenbeam-ita opened this issue Mar 23, 2025 · 2 comments
Open

Comments

@greenbeam-ita
Copy link

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,
  },
Image

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
Image

Additional information

No response

@posva posva added the need repro label Mar 23, 2025 — with Volta.net
@greenbeam-ita
Copy link
Author

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"
  }
}

@greenbeam-ita
Copy link
Author

Anyone can help here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants