Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline not working and error caught (in promise) non-precached-url: non-precached-url :: [{"url":"/"}] #16

Open
ttijl opened this issue May 2, 2023 · 7 comments

Comments

@ttijl
Copy link

ttijl commented May 2, 2023

Hello, when installing @vite-pwa/astro im having this issue. It seems like it isnt working offline and im getting this error: caught (in promise) non-precached-url: non-precached-url :: [{"url":"/"}].

here is a minimal example of the issue. https://github.com/ttijl/astro-pwa-issue

@userquin
Copy link
Member

userquin commented May 2, 2023

@ttijl you're using output: 'server', we need at least one html to use it as fallback, switching to output: 'static' build output contains the index.html file (/). I don't know if you can use server and force Astro to prerender some html page:

imagen

@userquin
Copy link
Member

userquin commented May 2, 2023

@ttijl check https://docs.astro.build/en/guides/server-side-rendering/#hybrid-rendering

EDIT: adding export const prerender = true; to index.astro with output: 'server':

imagen

@userquin
Copy link
Member

userquin commented May 2, 2023

It works:

imagen

@ttijl
Copy link
Author

ttijl commented May 2, 2023

Thank you, that works.
One other question, how can i make the PWA network-first. So only using cache if network isnt working

@userquin
Copy link
Member

userquin commented May 2, 2023

@ttijl the problem is precaching, check this issue, you'll need to add a custom sw: GoogleChrome/workbox#1767

You can also check this PR patching workbox-preload module to make the update quicker, you should check how to apply the patch using yarn: vite-pwa/docs#41

@ttijl
Copy link
Author

ttijl commented May 3, 2023

Custom SW is only possible with InjectManifest right? And that does not work with Astro? I also tried this: https://vite-pwa-org.netlify.app/workbox/inject-manifest.html#network-first-strategy

@userquin
Copy link
Member

userquin commented Jun 1, 2023

Custom SW is only possible with InjectManifest right?

yes

And that does not work with Astro?

why not? it should work

I also tried this: https://vite-pwa-org.netlify.app/workbox/inject-manifest.html#network-first-strategy

and?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants