next-pwa: nextjs v12 bad-precaching-response
Summary
Got error in console:
workbox-4a677df8.js:1 Uncaught (in promise) bad-precaching-response: bad-precaching-response :: [{"url":"https://***.com/_next/server/middleware-manifest.json","status":404}]
Versions
next-pwa: v5.4.0next: v12.0.1
How To Reproduce
Steps to reproduce the behavior:
- Install the latest nextjs
npx create-next-app -e with-tailwindcss my-project - delete
yarn.lockfile and install latest next and pwayarn add next@latest next-pwa - create
next.config.jsconst withPWA = require('next-pwa') module.exports = withPWA({ pwa: { dest: 'public' } }) - run
yarn build - run
yarn start
See an error in console.
Expected Behaviors
The file exists but is not accessible for some reason.
Screenshots

Additional Context
Is it possible that this is related to some updates in nextjs.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 41
- Comments: 75 (7 by maintainers)
Commits related to this issue
- Updated dependencies - `bad-precaching-response` from [next-pwa](https://github.com/shadowwalker/next-pwa/issues/288) — committed to AGS1130/dev by deleted user 3 years ago
- Fix bad-precaching-response https://github.com/shadowwalker/next-pwa/issues/288 — committed to interclip/next by filiptronicek 3 years ago
- try a different setup, as per https://github.com/shadowwalker/next-pwa/issues/288 — committed to MugishaU/portfolio_v2 by MugishaU 3 years ago
- Fix bad precaching error https://github.com/shadowwalker/next-pwa/issues/288 — committed to veganhacktivists/veganhacktivists by JoaquinTrinanes 3 years ago
- fix: bad-precaching-response from building locally - Reference https://github.com/shadowwalker/next-pwa/issues/288#issuecomment-1703859596 — committed to sonastea/misorter by sonastea 6 months ago
- feat: view featured lists from the fire emoji button toggle (#9) * feat: add visit model & superjson for serializing json - Bump misorter to v1.4.0 * feat: switch to superstruct from zod * f... — committed to sonastea/misorter by sonastea 6 months ago
quick fix
next.config.js
I don’t think this would cause any issues in practice but there should probably be a backslash before the dot inside the RegEx.
I am still experiencing this issue with
"next-pwa": "5.6.0"and"next": "^12.3.2-canary.26":My config:
I too am still having an issue with this

I still encounter this issue with 5.4.1 using:
@FDiskas
please reopen the issue as the same still happens
Btw, getting the same thing if you have _offline page defined. adding it to buildExcludes array works, but I don’t think that should be excluded?
I don’t have a clue how this stuff even works lol, I’m pretty new to PWA’s so can’t help you there. Just wanted to try nextjs 12 and noticed the pwa tab in lighthouse broke, so here I am.
For me, this happened after:
sw.jsfile in my/publicdir, and thennpm run dev.After manually deleting
sw.jsI no longer had issues.I also updated my
package.jsonas follows:Same here with:
I’m also getting this warning:
@shadowwalker
I got the same error and fixed with above workaround.
Then I got those errors with Preact+NextJS through Preact plugin.
and fixed by removing Preact. How can I fix this?
not working(((
Hello! This fix has worked for me, but lighthouse seems to break when trying to run a test. It hangs up forever and produces the following error:
Uncaught (in promise) DOMException: Failed to register a ServiceWorker for scope...Any ideas? Thanks! 🙌
facing the same issue
Add thumbs up and hit subscribe button. You don’t need to ping everybody. In my case provided workaround worked
just adding a +1, getting the same error.
I added an empty _middleware.ts function in the /pages directory and it seems to at least register the SW now, but I’m still getting the bad-precaching-response.
Still not fixed in 5.6.0, getting a similar error myself:
Uncaught (in promise) bad-precaching-response: bad-precaching-response :: [{"url":"http://localhost:8084/_next/static/503s2A1ywwygIF0aaUq6z/_buildManifest.js","status":404}][21/08/22]
@shadowwalker this issue exists again since the last release:
Hi guys, it seems he has stopped working since December 2021. 😥
@TimoWilhelm it doesn’t help with next 12.0.9 and next-pwa 5.4.4
Does anyone know what the impact of excluding the
middleware-manifest.jsonfile as part of the build?It does seem to fix issue by removing any references in the compiled
sw.jsfile but I’m wary of just removing a file without understanding what it does…Same problem here
Solved by v5.4.1?
Also facing this issue on next 12.0.3 and next-pwa 5.4.0.
Having this exact same problem, currently.
same issue for me
When using nested middlewares and middleware-chunks, this has done the trick for me:
Hey @FDiskas to be honest, i’ve tried almost every single suggestion i have found so far. Sadly nothing works
Still not working 😭 Using:
"next": "^12.1.0""next-pwa": "^5.4.6"My config:
UPDATE: I did try almost everything, nothing helps so far. App is deployed on heroku just FYI, not sure if this makes any difference but just in case…
Indeed @sfiquet , I’m experiencing the same issue.
Should be solved so far
Same problem here, the requested
middleware jsonfile does not exist, neither aserverfolder inside_nextexists, there are only__privateand_staticfolder there. At least on Vercel, on localhost exists the.nextfolderFaced the same issue with next version 12.0.2. Excluding middleware-manifest.json worked.
same issue just when bumping next.js version to 12.0.2, without using any _middleware
Didn’t notice this before but yeah, I’ve got the same issue. Unchecking the “Clear storage” option in Lighthouse seems to help.
Edit: I’m actually not sure it’s related to Next v12. Just tried running Lighthouse against our production site which is still running on Next 10.0.8 and I’m getting the same issue there. Maybe it’s a new Chromium bug? I’m certain Lighthouse used to work with no issues in the past.