-
-
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
Progressive Web Application Dynamic Route Problem with vite-pwa-nuxt in nuxt3 #79
Comments
Check this draft PR: #66 Problem 1 and 2: Problem 3 and 4: |
Problem 1 and 2: mp4 extension is added for globpattern and the video is 1.85 mb and yet it doesn't work. mp4 route: /video/a.mp4 Problem 3 and 4: For example; I am trying to access localhost:3000/verify/email/142412421 (142412421 is a random token. ) How can I code it? Can you help me? Thanks |
Problem 1 and 2: Problem 3 and 4: workbox: {
/*
Adding the regex will prevent the offline controller to intercept this url.
If missing, then will always redirect to navigateFallback url (default is /) on page refresh (offline or online).
*/
navigateFallbackDenylist: [/^\/verify\/email\/.*/i],
/*
This handler will send the request to the backend without caching the response (cacheWillUpdate).
When offline, the request to the backend will fail and will redirect to /error page (handlerDidError).
*/
runtimeCaching: [{
urlPattern: ({ url, sameOrigin }) => sameOrigin && url.pathname.match(/^\/verify\/email\/.*/i),
handler: 'NetworkOnly',
options: {
matchOptions: {
ignoreVary: true,
ignoreSearch: true
},
plugins: [{
handlerDidError: async () => Response.redirect('/error', 302),
cacheWillUpdate: async () => null
}]
}
}]
} |
upps both regex are wrong, should be |
I will give a lot of details to express myself much more clearly. Problem 1-) I have many dynamic pages like the URLs below. I cannot access any of these pages. /verify/email/214214 /verify/password/412412 /refund/412421 exc. Problem 2-) It doesn't matter if it is dynamic or static, when I refresh the page on any URL, it sends it to the home page. How can I fix this? Question 3-) There are folders such as css, scss in the Assets folder, img and video in the public folder and they are full. Almost all of them give errors. The error example is as follows. Note: The code you posted did not work for me. Thanks pwa: {
useCredentials: true,
registerType: "autoUpdate",
includeAssets: [
"apple-touch-icon.png",
"android-chrome-192x192.png",
"android-chrome-512x512.png",
"favicon.ico",
"favicon-16x16.png",
"favicon-32x32.png",
"mstile-150x150.png",
"safari-pinned-tab.svg",
],
manifest: {
name: "Find Your Virtual Assistant",
short_name: "Fiyuva",
description:
"Fiyuva is a platform that provides quality service to its customers in many sectors.",
theme_color: "#110F0F",
start_url: process.env.BASE_URL,
id: "/",
scope: process.env.BASE_URL,
orientation: "any",
icons: [
{
src: "/img/pwa/android-chrome-192x192.png",
type: "image/png",
sizes: "192x192",
form_factor: "narrow"
},
{
src: "/img/pwa/android-chrome-512x512.png",
type: "image/png",
sizes: "512x512"
},
{
src: "/img/pwa/android-chrome-512x512.png",
type: "image/png",
sizes: "512x512",
purpose: "any"
},
{
src: "/img/pwa/android-chrome-512x512.png",
type: "image/png",
sizes: "512x512",
purpose: "maskable"
},
],
display_override: ["fullscreen", "minimal-ui", "standalone"],
shortcuts: [
{
name: "Home Page",
url: "/",
description: "Home Page",
icons: [
{
src: "/img/pwa/android-chrome-96x96.png",
sizes: "96x96",
type: "image/png",
purpose: "any",
},
],
},
{
name: "Sectors",
url: "/sectors",
description: "Sectors Page",
icons: [
{
src: "/img/pwa/android-chrome-96x96.png",
sizes: "96x96",
type: "image/png",
purpose: "any",
},
],
},
{
name: "About",
url: "/about",
description: "About Page",
icons: [
{
src: "/img/pwa/android-chrome-96x96.png",
sizes: "96x96",
type: "image/png",
purpose: "any",
},
],
},
{
name: "Contact",
url: "/contact",
description: "Contact Page",
icons: [
{
src: "/img/pwa/android-chrome-96x96.png",
sizes: "96x96",
type: "image/png",
purpose: "any",
},
],
},
{
name: "Login",
url: "/login",
description: "Login Page",
icons: [
{
src: "/img/pwa/android-chrome-96x96.png",
sizes: "96x96",
type: "image/png",
purpose: "any",
},
],
},
{
name: "Register",
url: "/register",
description: "Register Page",
icons: [
{
src: "/img/pwa/android-chrome-96x96.png",
sizes: "96x96",
type: "image/png",
purpose: "any",
},
],
}
],
protocol_handlers: [
{
protocol: "mailto",
url: process.env.BASE_URL + "/newEmail?to=%s",
},
],
},
workbox: {
globPatterns: ['**/*.{js,ts,css,scss,png,webp,svg,mp4,vue}'],
navigateFallback: "/",
navigateFallbackDenylist: [/^\/verify\/email\/.*/i],
runtimeCaching: [{
urlPattern: ({ url, sameOrigin }) => sameOrigin && url.pathname.match(/^\/verify\/email\/.*/i),
handler: 'NetworkOnly',
options: {
matchOptions: {
ignoreVary: true,
ignoreSearch: true
},
plugins: [{
handlerDidError: async () => Response.redirect('/error', 302),
cacheWillUpdate: async () => null
}]
}
}]
},
devOptions: {
enabled: true,
type: "module"
},
}, Examples of errors I receive are as follows. workbox No route found for: /_nuxt/assets/css/Shared/sf.css?vue&type=style&index=0&src=e1198cb5&scoped=e1198cb5&lang.css
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/assets/css/Shared/wp.css?vue&type=style&index=1&src=e1198cb5&scoped=e1198cb5&lang.css
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/assets/css/Shared/wp.css?vue&type=style&index=1&src=e1198cb5&scoped=e1198cb5&lang.css
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/assets/css/footer.css?vue&type=style&index=0&src=04e04d11&scoped=04e04d11&lang.css
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/assets/css/footer.css?vue&type=style&index=0&src=04e04d11&scoped=04e04d11&lang.css
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/pages/sectors.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/pages/sectors.vue
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/pages/about.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/pages/about.vue
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/pages/contact.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/pages/contact.vue
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/components/AppCpf.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/components/AppCpf.vue
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/assets/css/pageimg.css?vue&type=style&index=0&src=10b9b775&scoped=10b9b775&lang.css
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/assets/css/pageimg.css?vue&type=style&index=0&src=10b9b775&scoped=10b9b775&lang.css
workbox Precaching did not find a match for /_nuxt/components/About/FiyuvaDesc.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/components/About/FiyuvaDesc.vue
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/components/Home/MainSectors.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/components/Home/MainSectors.vue
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/components/Home/ThreeBoxes.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/components/Home/ThreeBoxes.vue
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/components/Home/WorkWithUs.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/components/Home/WorkWithUs.vue
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/components/AppDeneme.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/components/AppDeneme.vue
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/components/Home/CustomerComments.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/components/Home/CustomerComments.vue
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/components/AppAds.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/components/AppAds.vue
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/components/Shared/AppScrollToTop.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/components/Shared/AppScrollToTop.vue
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/components/Shared/AppWpContact.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/components/Shared/AppWpContact.vue
workbox-5357ef54.js:62 workbox Precaching did not find a match for /_nuxt/components/Shared/AppFooter.vue
workbox-5357ef54.js:62 workbox No route found for: /_nuxt/components/Shared/AppFooter.vue |
@Fiyuva seems you have a sw installed, remove it from dev tools, these logs seems to be in dev mode, on dev server any entry in workbox is ignored, to test the pwa try running the build + preview: EDIT: don't add scss, vue and ts extensions, once you build your app there will be only js and css assets |
can you see any errors in the code? |
|
I removed includeAssets and added ico and svg to workbox.globPatterns If you want to add only those listed in current includeAssets add a new entry in workbox.globPatterns per includeAssets (copy/paste the list entries) What do u mean in this sentence? I didn't understand well. Can you give me basic example |
@Fiyuva globPatterns: ['**/*.{js,css,png,webp,mp4}', 'safari-pinned-tab.svg'], If you add Check also this entry: https://vite-pwa-org.netlify.app/guide/cookbook.html |
if i want to add some png, jpg, ico and exc. files i will add them like this right? |
yes: search globPatterns here https://developer.chrome.com/docs/workbox/reference/workbox-build/ => https://github.com/isaacs/node-glob#glob-primer |
Thank you for everything :) |
my pwa code is as follows. I need your help on a few issues.
Problem 1-) Precaching error;
workbox Precaching did not find a match for /video/fa.mp4
Problem 2-) No route error; workbox No route found for: /video/fa.mp4
Problem 3-) I cannot access the dynamic route. When I try to access it, it redirects to the home page. Why?
Problem 4-) When I refresh the page, it redirects to the home page.
Thanks
pwa: { useCredentials: true, registerType: "autoUpdate", includeAssets: [ "apple-touch-icon.png", "android-chrome-192x192.png", "android-chrome-512x512.png", "favicon.ico", "favicon-16x16.png", "favicon-32x32.png", "mstile-150x150.png", "safari-pinned-tab.svg", ], manifest: { name: "Find Your Virtual Assistance", short_name: "Fiyuva", description: "Fiyuva is a platform that provides quality service to its customers in many sectors.", theme_color: "#110F0F", start_url: process.env.BASE_URL, id: "/", scope: process.env.BASE_URL, orientation: "any", icons: [ { src: "/img/pwa/android-chrome-192x192.png", type: "image/png", sizes: "192x192", form_factor: "narrow" }, { src: "/img/pwa/android-chrome-512x512.png", type: "image/png", sizes: "512x512" }, { src: "/img/pwa/android-chrome-512x512.png", type: "image/png", sizes: "512x512", purpose: "any" }, { src: "/img/pwa/android-chrome-512x512.png", type: "image/png", sizes: "512x512", purpose: "maskable" }, ], display_override: ["fullscreen", "minimal-ui", "standalone"], shortcuts: [ { name: "Home Page", url: "/", description: "Home Page", icons: [ { src: "/img/pwa/android-chrome-96x96.png", sizes: "96x96", type: "image/png", purpose: "any", }, ], }, { name: "Sectors", url: "/sectors", description: "Sectors Page", icons: [ { src: "/img/pwa/android-chrome-96x96.png", sizes: "96x96", type: "image/png", purpose: "any", }, ], }, { name: "About", url: "/about", description: "About Page", icons: [ { src: "/img/pwa/android-chrome-96x96.png", sizes: "96x96", type: "image/png", purpose: "any", }, ], }, { name: "Contact", url: "/contact", description: "Contact Page", icons: [ { src: "/img/pwa/android-chrome-96x96.png", sizes: "96x96", type: "image/png", purpose: "any", }, ], }, { name: "Login", url: "/login", description: "Login Page", icons: [ { src: "/img/pwa/android-chrome-96x96.png", sizes: "96x96", type: "image/png", purpose: "any", }, ], }, { name: "Register", url: "/register", description: "Register Page", icons: [ { src: "/img/pwa/android-chrome-96x96.png", sizes: "96x96", type: "image/png", purpose: "any", }, ], } ], protocol_handlers: [ { protocol: "mailto", url: process.env.BASE_URL + "/newEmail?to=%s", }, ], }, workbox: { globPatterns: ['**/*.{js,ts,css,scss,png,webp,svg,mp4,vue}'], navigateFallback: "/" }, devOptions: { enabled: true, type: "module" }, }
The text was updated successfully, but these errors were encountered: