-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Extremely weird routing bug(s) #74
Comments
check antfu/vitesse-nuxt#98 and #66 EDIT: some explanations here with SvelteKit (same problem with same solution): vite-pwa/sveltekit#65 (comment) |
@bogdanciuca yes, it is about dynamic pages: should be excluded with denylist and runtime caching entry, the current PR is too complex to be solved programatically, ppl can have distinct caching strategies and options (per route, per routes group...). My suggestion, include custom runtime caching for those routes. NOTE bout the draft PR: I need to do some research, but it won't be merged anytime soon (or maybe ever) |
@userquin I see, thanks for the additional context! Should I then also exclude static files with denylist / runtime caching entry? What about the catch all route? |
@bogdanciuca since you're using About the catch all route, I suggest you to use custom Nuxt error page or use the default provided by Nuxt, you can check an example in the elk.zone repo. You don't need to do anything special for it. |
@userquin all my pages, including "dynamic" ones are currently generated. Although I've seen the issue in By static files I mean assets (i.e. PDF files). They don't seem to load in the browser, as mentioned above. Maybe this is a different issue?
Regarding the catch all route, I'm using this. |
do you have an html page per dynamic route in the output build? If so, check my PR in vitesse-nuxt repo, instead the default page you should redirect to the prerendered route in the runtime caching
Are the pdf files in the public folder? If so you can add the pdf extension to
You don't need to do anything |
Yes, I do. Will check your PR, although I haven't encountered any issues with them so far.
Yes, of course, a subfolder of public. I will try to add the PDF extension, although the issue occurs when online (haven't tested it offline).
Hmm, |
About pdf files, if you dont add them to the sw precaching (globPattern) you need to add .pdf files to the denylist ( |
Check the service worker in the elk.zone repo (service-worker/sw.ts), check the denylist entries |
I'll give it a try and get back with an update. Thanks again for all your help! |
You dont need to include a custom sw , generateSW will generate similar code in elk, any resource not in the sw precache manifest should be excluded from sw nav controller (denylist) and optionallly included in a custom runtime caching if required |
@userquin got a chance to test your suggestions and they worked, thanks again! |
@userquin sorry to bother you again, but it seems I can still reproduce the PDF issue. I recently replaced the old PDF with a much larger one (~48MB). Any idea why this would happen? Are there any size constraints? Update: I managed to get the file size down to 3.5MB via compression. It still redirects to |
@bogdanciuca if the PDF is added to the sw precache manifest then check this https://vite-pwa-org.netlify.app/guide/faq.html#missing-assets-from-sw-precache-manifest EDIT: you should have a warning in the console when building... workbox just shows a warning, should be an error |
@userquin I was wondering why my other files were working, being under 2MB. Thank you! 🙇 PS: That piece of documentation might be better placed somewhere else, a place a bit more visible than FAQ, if I may suggest. |
@bogdanciuca because workbox build shows the warning and remove the entry from sw precache manifest, then requesting the pdf will be intercepted by the sw and the controller will use the fallback. IIRC in previous comments I mention 2 solutions for the PDF:
|
any suggestion are welcome (and PR ;) ) |
The thing is that I wasn't getting any warning...
Yes, I went with adding the extension to
Will do! |
It seems that in various scenarios, the app inconsistently redirects to
/
.I first encountered this behaviour when trying to directly access a non-existing route (i.e. https://vitesse-nuxt3.netlify.app/non-existing-route) and then hit refresh. Sometimes it happens after the first refresh, but usually after at most four refreshes, the redirect occurs.
This also happens consistently when using
NuxtLink
withhref="/some-route"
andtarget="_blank"
. Instead of loading the catch all route, the app redirects to/
.After further testing, it seems to happen on existing routes too (i.e. https://vitesse-nuxt3.netlify.app/hi/antfu). Same behaviour, after 1-4 refreshes, it redirects to
/
.Furthermore, when using SSG and linking static files (i.e. PDFs in my case), they never load when clicking the
NuxtLink
, but redirect to/
. They can be accessed directly, but after loading the app, this stops working too.My current workaround is to disable
pwa
alltogether, so any suggestions are appreciated!The text was updated successfully, but these errors were encountered: