-
-
Notifications
You must be signed in to change notification settings - Fork 235
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
fix(pwa): dynamic hi
route and F5
#98
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for vitesse-nuxt3 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
# Conflicts: # package.json
I Will try to use custom plugins to avoid cache hi entries and make it working when offline and missing from cache |
@@ -1,13 +1,31 @@ | |||
<script setup lang="ts"> | |||
const router = useRouter() | |||
const route = useRoute() | |||
const online = useOnline() | |||
const hiOffline = ref(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can switch this to message and change it in checkHiOnline
{ | ||
handler: 'NetworkFirst', | ||
urlPattern: ({ sameOrigin, url }) => sameOrigin && url.pathname.startsWith('/hi/'), | ||
options: { | ||
plugins: [{ | ||
handlerDidError: async () => Response.redirect('/hi', 302), | ||
cacheWillUpdate: async () => null, | ||
}], | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It it possible to identify dynamic routes automatically in the Nuxt module? This is a starter template after all, hard code those path isn't really helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I'll try to add it to the module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR includes:
hi
route even when offline, if the entry is cached it will work (press F5 once entered a name and before going offline): a lot of work per dynamic routeIf the
/hi/<name>
route is not in thehi-id-cache
, thehandlerDidError
plugin will redirect to/
.EDIT: sometimes
useOnline
is not working, maybe some hydration/client problem, there is no warning/error.This will work only when using
build + start
scripts, usinggenerate + start:generate
scripts will not work since node/express will return 404 for the dynamic route and will not be cached.