create-next-pwa icon indicating copy to clipboard operation
create-next-pwa copied to clipboard

Cannot make it instalable with Github pages

Open waghcwb opened this issue 3 years ago • 0 comments

I'm trying to make a static pwa with next.js and tailwind.

Steps

  1. Use create-next-pwa:
npx create-next-pwa pwa-test --tailwind
  1. Install gh-pages dependency and update package.json
"scripts": {
	"dev": "next dev",
	"build": "next build && next export",
	"start": "next start",
	"format": "prettier --write \"./**/*.{js,json}\"",
	"predeploy": "npm run build",
	"deploy": "gh-pages -d out -t true"
},
  1. Update next.config.js
const withPWA = require('next-pwa');

module.exports = withPWA({
	basePath: '/temp',
	pwa: {
		dest: 'public',
		register: true,
		skipWaiting: true
	}
});
  1. Run deploy script (you need to setup the remote repo) npm run deploy

In development mode, the pwa is instalable and works fine. But when I run next export and add the static site to Github pages, I always get this error:

No matching service worker detected. You may need to reload the page, or check that the scope of the service worker for the current page encloses the scope and start URL from the manifest.

image

waghcwb avatar Mar 12 '22 22:03 waghcwb