Comments (8)
If we don't use PWA it works fine, but with PWA it goes to /
Because any server page is missing from sw precache and the sw will return the content of /, if you exclude /test from sw interception (add that route to workbox.navigateFallbackDenylist
), it should work: beware, when offline browser offline page will be there when requesting /test
.
For example, if you go to https://vitesse-nuxt3.netlify.app/, enter aaa
in the input, click the Go button and then refresh the page once in /hi/aaa
page, you can check the response in the network tab, the request being intercepted by the sw returning the / page content.
from docs.
Also happening to me. Did you find a solution @prstwo ?
from docs.
When using a meta framework we need to deal with server pages. We need the context where the PWA will run in the client, for example:
- do you have server pages (when using Nuxt, are you using
nuxi generate
ornuxi build
)? - are you generating static pages (
nitro.prerender
)? - do you have protected pages (sign-in)?
A simple workaround for Nuxt will be an empty index.vue
page (use it as the fallback for offline: navigateFallback: '/'
), then add a simple middleware (only for client) to redirect/navigate to the home page (if you've protected pages, you can use the auth middleware redirecting to the protected home page when signed-in): check this middleware https://github.com/elk-zone/elk/blob/main/middleware/auth.ts and the index.vue page in the elk.zone repo.
Any api call and server page should be excluded from the sw interception: for server pages, you should add the required logic to avoid accessing those server pages if you're offline (you can also use a simple client middleware with offline logic redirecting to some page or just throw an error and handle it in a custom error page): check https://github.com/elk-zone/elk/blob/main/service-worker/sw.ts#L36-L50 (you can use workbox.navigateFallbackDenylist
if using generateSW
strategy).
from docs.
Thanks for your response @userquin
In my case I am deploying to Vercel and I have protected pages.
I'm not totally sure if I understand the middleware part. It seems you want to always get the user to a default page, but we wanted them to enter the page they navigated to. So, for example:
User enters /test and he gets redirected to /
We want the user to enter /test and stay there
If we don't use PWA it works fine, but with PWA it goes to /
from docs.
In previous example, the hi
route excluded in Nitro prerender, and so the html page will be missing and the entry in the sw precache manifest also missing: https://github.com/antfu/vitesse-nuxt3/blob/main/nuxt.config.ts#L36-L39.
Nuxt by default will exclude any page when using build command. In the example we exclude the hi route.
from docs.
I confirm this works. Thank you again @userquin, you are very helpful
from docs.
When I include '@vite-pwa/nuxt' in modules I get data-ssr="false".
Is this related?
from docs.
Check vite-pwa/nuxt#74
from docs.
Related Issues (20)
- automatic cutting
- Typo HOT 6
- Doc around caching strategy is confusing. HOT 4
- How to set ignoreVary for matching cache in ? HOT 2
- self.skipWaiting is not a function HOT 6
- `devTools.enabled` in strategy `generateSW` breaks due to wrong `globDirectory` HOT 1
- No workbox debug logs in with `devtools.enabled` and strategy `injectedManifest` HOT 1
- Where to put the manifest generated data? HOT 4
- [BUG]: custom envPrefix doesn't work when building
- Cleaning local storage on automatic reload
- Add an example to implement Push Notifications? HOT 6
- Is it possible to change the index.html file name?
- Warnings on setting up a new workspace HOT 1
- Server keeps reloading in dev-mode on GET requests
- Create manifest.webmanifest in a sub directory of public HOT 3
- Ability to track download progress?
- Service Worker "import sentry-release-injection" error when loading page
- If I want to create a big data screen, how do I know the website where I installed it?
- "@vite-pwa/nuxt": "^0.1.1" - manifest.webmanifest is 404 HOT 1
- Generate PWA icons using favicon.inbrowser.app HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docs.