Repository navigation
Replies: 3 comments 2 replies
|
I file an issue to add an enhacement on |
2 replies
|
Check the comment on the issue, there is a repo with the solution: |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This is an analysis of #159, but for dynamic routes; the problem here is that we need to handle it from client (service worker) and server side:
index.htmlwhen something missing is requested, in our case, for any pathhi/:name, the server will return the content ofindex.htmland so the flashing appears.index.htmleven when the server can serve the content of the dynamic page.Following I will describe a prove of concept that works, but we need to manually configure the app. I have push here https://github.com/userquin/vitesse/tree/chore/fix-missing-routes-on-sw the working project, to run it once cloned on local machine, from the root folder:
pnpm run build && pnpm run serveOpen
https://localhostand try F5 onhiroute.Step one, include dynamic routes generation:
nuxtStyleonvite-plugin-pagesconfigurationextendRoutetovite-plugin-pagesconfiguration to just skip only_.vue: the configuration for previous and this step will be:includedRoutestossgOptionsforvite-ssg:_instead: rename[...all].vueandhi/[name].vuepages to_.vueandhi/_name.vuerespectivellyStep 2, configure server to serve dinamyc routes:
I've included a modified version for
https-localhostusing expressstaticwithfallthroughenabled, that is, when missing resource, the middleware will just callnextin the chain and then we intercept the request:At this point, we are able to serve dynamic routes content from server (there is no SSR at all, the client will just change the title once
hi/_name.htmlwith all its assets loaded).But the service worker will still serve the
index.html. If you make a hard refresh the flash dissapear, while using just F5 you will see the flashing.Step 3, configure the service worker to serve dynamic routes content.
The problem is that we cannot use
generateSWsince there is no way to change the default routing, that is, all request that doesn't do an exact match will fallback toindex.html, just open the service worker onnetlifyand you will find this entry at bottom ofsw.jsfile:To solve the problem, I have included a custom service worker to build a new one with the changes:
and also update the
PWAPluginconfiguration with:All reactions