Uncaught (in promise) non-precached-url: non-precached-url :: [{"url":"/"}]
meliceanu opened this issue · 19 comments
Is there a way to get rid of this error?
I tried to use the config https://vite-pwa-org.netlify.app/guide/service-worker-precache.html but nothing seems to work, i use Nuxt 3.12.3 and @vite-pwa/nuxt 0.9.1
Thank you
You need to prerender / route, workbox requires the html to be there to allow work offline (precaching): don't use vite plugin pwa, use the nuxt integration
how can i do that? do i need to add a index.html file in the root even tho i don't need it?
somehow the error still appears, only in production. it's hosted on netlify
open devtools and remove sw, then page refresh
it just automatically reregisters the sw, with the same error
can you check if working in your local with build/generate? (follow nuxt instructions once build/generate command finish)
EDIT: remove the edge preset
ok i removed the edge preset and kept the prerendering of the / page in the route. but the error is still there
check dist or output folder, you should have the html file there, some questions:
- ssr enabled?
- how do you build the app (build or generate command)?
The index.html should be in the sw.js file, check the sw.js file at the end, there should be something like:
{ url: "/", revision: "xxxxxx" }
ssr is enabled i build the app using pnpm run build. in my sw.js file i dont see any url: "/"
this is what i think is the / page:
{ url: '_payload.json', revision: 'fc92125330b4f4ac06b2d1f6acfaff6d' },
all my other pages are:
{ url: 'example-route/_payload.json', revision: 'fc92125330b4f4ac06b2d1f6acfaff6d' },
did you add nitro.prerender.routes
with /
in the array?
i did, the error keeps appearing
is the prerendering a must? it seems it's not working
why are you removing html files from glob patterns? remove that entry https://vite-pwa-org.netlify.app/guide/static-assets.html#globpatterns
you're removing sw precaching, your app will not work when offline
remove workbox entry, check if the html pages being generated in the output folder
So i had to remove nay reference to the manifest or manifest.webmanifest, deleted the file as well. The pwa options handel the manifest. Note the scope and the theme-color options.
I had to change the app.vue configuration cause i use the assets generator:
Corrected Nitro configuration, you don't really need the preset, it's just personal choice. Need to prerender the '/' route
If you then have the bad-precaching-response, with a 404 status, you have to exclude that file/url from the pwa build:
All of this thanks to @userquin