Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Currently you are not able to use auth module without a service account #1510

Closed
tux2nicolae opened this issue Mar 24, 2024 · 0 comments
Closed

Comments

@tux2nicolae
Copy link

tux2nicolae commented Mar 24, 2024

Reproduction

const adminAuth = getAdminAuth(firebaseAdminApp)

Steps to reproduce the bug

  1. Enable auth module
  vuefire: {
    auth: {
      enabled: true,
    },
    ...
  }
  1. Make sure you don't have the GOOGLE_APPLICATION_CREDENTIALS set

  2. Run npm run dev or build for production

Expected behavior

You should be allowed to use auth module without a service account

Actual behavior

You get this error when using the auth module without a service account specified.

The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services


I think the problem comes from here

const adminAuth = getAdminAuth(firebaseAdminApp)

the getAdminAuth() is always called regardless of the fact you may not have a service account.

If you move the const adminAuth = getAdminAuth(firebaseAdminApp) inside the if block if (auth.currentUser?.uid !== uid) the problem goes away, or maybe it should be here

addPlugin(resolve(runtimeDir, 'auth/plugin-authenticate-user.server'))

to add a if block if (nuxt.options.ssr && hasServiceAccount)

Additional information

Our use case is that, we don't have a service account because we don't need to render anything on the server based on authentication state, we are only using authentication on client side in some <client-only /> components

@vuejs vuejs locked and limited conversation to collaborators Mar 25, 2024
@posva posva converted this issue into discussion #1511 Mar 25, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant