next-pwa
next-pwa copied to clipboard
service worker script returns 404
Summary
Hi, it seems that something has been broken in the latest release (5.5.5). The necessary files (sw.js etc.) do not get generated in /public anymore.
Versions
-
next-pwa
: 5.5.5 -
next
: 12.2.2
How To Reproduce
Steps to reproduce the behavior:
- Go to this codesandbox
- wait for it to start
- see the error message
Link to minimal reproduce setup repository if any. https://codesandbox.io/s/bitter-breeze-xcpdqh
Expected Behaviors
sw.js and workbox-[hash].js should be generated in public folder
Screenshots

Additional Context
Might not get noticed until deployed if files are still in the filesystem from before the upgrade.
Best, Michel
We are also suffering this issue - seems to be a breakage in 5.5.5
It seems to be ignoring settings passed in now?
v5.5.5
> [PWA] Compile client (static)
> [PWA] Auto register service worker with: XXXX\node_modules\next-pwa\register.js
> [PWA] Service worker: XXX\src\site\.next\sw.js
> [PWA] url: /sw.js
> [PWA] scope: /
v5.5.4:
> [PWA] Compile client (static)
> [PWA] Auto register service worker is disabled, please call following code in componentDidMount callback or useEffect hook
> [PWA] window.workbox.register()
> [PWA] Service worker: XXXX\src\site\public\sw.js
> [PWA] url: /sw.js
> [PWA] scope: /
Config:
pwa: {
dest: 'public',
register: false,
skipWaiting: false,
buildExcludes: [/.map$/],
},
Having the same issue after updating to 5.5.5. After rollback to previous version it was fine again. The sw.js and workbox file weren't generated into /public (dest) anymore.
I noticed that bug after the PWA wasn't updating itself on android chrome anymore since service worker was 404.
should be in /public instead of /.next:
> [PWA] Service worker: /Users/workspace/mono/app-client/.next/sw.js
> [PWA] url: /sw.js
Also, if I write SW in options to look for different serviceWorker.js files in the public folder, it's not looking for the same.
#372 may resolve this problem.
I am experiencing the same issue
How do i solve this for now?
The best fix is downgrading to version 5.5.4
ok, thanks
This PR is related to the issue, https://github.com/shadowwalker/next-pwa/pull/368
@Lukasdotcom any tip is appreciated.
The best fix is downgrading to version 5.5.4
What is the compatible next version and pwa config in next.config.js that works with [email protected]? Locally I am able to run it fine (Lighthouse checkmark, PWA is correctly set) with [email protected] and this config:
pwa: {
dest: 'public',
// register: true,
// skipWaiting: true,
runtimeCaching,
buildExcludes: [/middleware-manifest.json$/],
},
However, when deployed to Vercel on production, Lighthouse shows there's no service worker:
Does not register a service worker that controls page and start_url
I've tried messing up with the config based on several issues of this repo, none of them seems to work in production.