next-pwa: next-pwa not working in Production Envrionment
Hello,
My Website => I am unable to use PWA on Production Environment on both Desktop & Mobile.
const withPWA = require('next-pwa');
module.exports = withPWA({
reactStrictMode: true,
pwa: {
dest: 'public',
sw: 'service-worker.js'
}
});
here is my next.config.js code, but it is not working on Production Environment, whereas it is working on Development Environment.
also, after upgrading the npm dependencies packages it’s not working on the Production Environment but working perfectly fine on Development Environment.
please help me @shadowwalker
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 4
- Comments: 18
Commits related to this issue
- PWA Fix # 1 Trying to fix issue where it doesn't work in production using this issue thread https://github.com/shadowwalker/next-pwa/issues/295 — committed to Umayarz18/portfolio by Umayarz18 3 years ago
- fix pwa setting based on https://github.com/shadowwalker/next-pwa/issues/295 — committed to kim-taewoo/knock-knock by kim-taewoo 2 years ago
@dhavalveera yesterday I went through different solutions I found and somehow PWA started to work after updating my config to
package versions:
before updating the config, I could not get PWA to work on prod
I dont really know if this helps you though.
Hi! I’m having the same problem. In the local environment everything works fine. In production, deployed with Cloudflare Pages, it doesn’t work because the service worker doesn’t get loaded. I’m using the latest version of next-pwa (
5.4.1). I also check thepackage-lock.jsonfile, and everywhere the version of workbox is6.4.1(Including packages likeworkbox-background-sync)next.config.js
When running
next build && next export, the filessw.jsandworkbox-XXXXXXXX.jsappear in theout director.Error message
out/_nextdirectory, I cannot find a file calledmiddleware-manifest.json(I’ve checked every dir). There is a file calledDcKWOchXOD8AY8wgjWFqP/_middlewareManifest.js, with this content.Does that mean that workbox is somehow is trying to load a file that it isn’t supposed to?
Worked for me!
Discussion’s been on going on #288 and so far this is the proposed solution, but people seem to have issues using _middleware.js and a custom error page after this.
This is not working for me. I confirmed the precaching error goes away but I cannot login to the app. Removing withPWA solves the problem.
This was not an issue before next 12 upgrade.
I’m using amplify.js to handle login via cognito and when I select sign-in the serviceworker loads a static chunk but the spinner just goes indefinitely… Not sure how to further debug this.
Edit: this works if I remove
The template use using an old version of the withPWA plugin so I updated it to the latest in the package.json
This worked for me! Thanks.