简体   繁体   中英

How to deploy web app with nuxt firebase?

I have installed the nuxt firebase plugin into my web app and when I serve the generated folder (dist) locally, it runs perfectly. But when I deploy it to the server, my web app doesnt even recognize any nuxt firebase command and causes an error like this.

在此处输入图像描述

Did I miss a configuration or something?

Here is the code to get the token

  let currentToken;
  try {
    const permission = await Notification.requestPermission()
    currentToken = await this.$fire.messaging.getToken();
    //console.log(currentToken);
    this.model.DeviceToken = currentToken;
  } catch (e) {
    console.error('An error occurred while retrieving token. ', e);
  }

I had a similar issue not too long ago. Double-check your firebase.json file. to ensure that when you are using the CLI it is set up to rewrite everything to index.html . It should look like this

{
  "hosting": {
    "public": "./dist",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html" <------
      }
    ]
  }
}

If that does not work you can try removing ServerMiddleware from nuxt.config.js and implementing it in its own module, as demonstrated in this answer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM