nuxt-community / firebase-module

🔥 Easily integrate Firebase into your Nuxt project. 🔥
https://firebase.nuxtjs.org
MIT License
640 stars 99 forks source link

Setting emulator port for Firestore and Database not working #634

Open eljass opened 1 year ago

eljass commented 1 year ago

Version

@nuxtjs/firebase: 8.2.2 firebase: 9.9.2 nuxt: 2.15.7

Reproduction Link

Steps to reproduce

// nuxt.config.js
const { NODE_ENV, FIRE_EMULATOR } = process.env
const isDev = NODE_ENV === 'development'
const isEmulator = FIRE_EMULATOR === 'true'

export default {
...
  firebase: {
    ...,
    services: {
      auth: {
          persistence: 'local',
          initialize: {
            onAuthStateChangedMutation: null,
            onAuthStateChangedAction: 'auth/ON_AUTH_CHANGED',
            subscribeManually: true,
          },
          ssr: {
            ignorePaths: ['/api'],
          },
          emulatorPort: isDev && isEmulator ? 9099 : null,
      },
      firestore: {
        memoryOnly: false,
        emulatorPort: isDev && isEmulator ? 8080 : null,
      },
      functions: false,
      storage: true,
      database: {
        emulatorPort: isDev && isEmulator ? 9000 : null,
      },
      performance: false,
      analytics: false,
      remoteConfig: false,
      messaging: false,
      terminateDatabasesAfterGenerate: true,
    }
  },
  ...
}

What is Expected?

It should be possible to set the port for each service seperately.

What is actually happening?

Setting emulator port in both configurations, firestore and database results FIREBASE FATAL ERROR: Cannot call useEmulator() after instance has already been initialized. on SSR.

This can be fixed by removing the emulatorPort field from database, and it will use an emulator, but according to docs, this should not be the case.