nuxt / vercel-builder

Vercel Builder for Nuxt
MIT License
645 stars 76 forks source link

The Service worker is installed but it does not allow me to install the app with @nuxtjs/pwa #654

Open GuasaPlay opened 2 years ago

GuasaPlay commented 2 years ago

Hello, this is the first time that I am deploying a nuxt app in Vercel and I have found a problem related to the PWA.

Make the recommended configuration for Service Worker to work as you can see below:

vercel.json

{
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder",
      "config": {
        "serverFiles": [
          "package.json"
        ]
      }
    }
  ],
  "routes": [
    {
      "src": "/sw.js",
      "continue": true,
      "headers": {
        "Cache-Control": "public, max-age=0, must-revalidate",
        "Service-Worker-Allowed": "/"
      }
    }
  ]
}

However, it does not show me the button to install the application from the web and from mobile.

image

Checking the service worker from the browser's developer tools, it can be seen that it is added correctly.

image

nuxt.config.js file

...
  pwa: {
    manifest: {
      lang: 'es',
    },
  },
...

package.json file

{
  "name": "educarty-frontend",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
    "lint:prettier": "prettier --check .",
    "lint": "yarn lint:js && yarn lint:prettier",
    "lintfix": "prettier --write --list-different . && yarn lint:js --fix"
  },
  "dependencies": {
    "@nuxtjs/axios": "^5.13.6",
    "@nuxtjs/pwa": "^3.3.5",
    "core-js": "^3.19.3",
    "nuxt": "^2.15.8",
    "vue": "^2.6.14",
    "vue-server-renderer": "^2.6.14",
    "vue-template-compiler": "^2.6.14",
    "webpack": "^4.46.0"
  },
  "devDependencies": {
    "@babel/eslint-parser": "^7.16.3",
    "@nuxt/postcss8": "^1.1.3",
    "@nuxtjs/eslint-config": "^8.0.0",
    "@nuxtjs/eslint-module": "^3.0.2",
    "@nuxtjs/vercel-builder": "^0.22.1",
    "autoprefixer": "^10.4.2",
    "eslint": "^8.4.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-nuxt": "^3.1.0",
    "eslint-plugin-vue": "^8.2.0",
    "postcss": "^8.4.6",
    "prettier": "^2.5.1",
    "tailwindcss": "^3.0.22"
  }
}

I really don't know what the problem is everything is in place, it would be very helpful if someone can help me solve this problem

danielroe commented 2 years ago

Would you provide a reproduction please? 🙏