nuxt-community / firebase-module

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

Messaging undefined #637

Open 93lucasp opened 1 year ago

93lucasp commented 1 year ago

Version

@nuxtjs/firebase: 8.2.2 firebase: 9.15.0 nuxt: 2.15.8

What is actually happening?

In the mounted $fire.messaging is undefined.

this is my configuration:

modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
    '@nuxtjs/auth-next',
    [
      '@nuxtjs/firebase',
      {
        config: {
          apiKey: "...",
          authDomain: "...",
          projectId: "...",
          storageBucket: "...",
          messagingSenderId: "...",
          appId: "...",
          measurementId: "..."
        },

        services: {
          messaging: {
            createServiceWorker: true,
            fcmPublicVapidKey: '...', 
            inject: fs.readFileSync('./serviceWorker.js') 
          },
        }
      }]
  ],

and this is the code inside the mounted:

 if (process.client) {
    console.log(this.$fire)
}

but it is undefined Schermata 2022-12-19 alle 17 24 27

Bishanta commented 1 year ago

I resolved the issue, after removing server property at the end of nuxt.config.js. FCM didn't work when my project wasn't running on localhost.

...other configs above

// Build Configuration: https://go.nuxtjs.dev/config-build build: { vendor: ['vue-i18n'], }, server: { //remove this server property entirely. host: "0.0.0.0" } }