Feature request: display a custom error page when a page is unavailable offline [gatsby-plugin-offline] #17569
Replies: 4 comments 1 reply
-
@davidbailey00 do we support this? I know workbox does https://developers.google.com/web/tools/workbox/guides/advanced-recipes#provide_a_fallback_response_to_a_route. Unsure if it's configurable with our offline plugin. |
Beta Was this translation helpful? Give feedback.
-
We don't currently have a way to configure a custom offline error page, so this behaviour is expected. You can use the new |
Beta Was this translation helpful? Give feedback.
-
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing! Thanks for being a part of the Gatsby community! 💪💜 |
Beta Was this translation helpful? Give feedback.
-
So is it still not possible to add custom offline page instead of "dino page" for better UX? My idea was to add global catch handler on requests and send offline page from cache in response:
{
resolve: 'gatsby-plugin-offline',
options: {
appendScript: 'src/utils/sw.ts',
precachePages: ['/offline'],
},
},
workbox.routing.setCatchHandler(() => {
// ignoreSearch to skip WB_REVISION query
return caches.match('/offline/index.html', { ignoreSearch: true })
}) But this approach doesn't work because gatsby/packages/gatsby-plugin-offline/src/gatsby-node.js Lines 110 to 114 in 1cfa511 If only we could add another exception in this array via some option... I was trying to add |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When i use "gatsby plugin offline" this work good in offline mode until user click page that he do not visit before. Then browser display no connection info and app crash.
What is the best approach to prevent for this?
For example if client click link to the subpage that he do not have in cache i want want to display mesage "This page is not available in offline mode" and block moving to this location.
Where can i find sample code to do this?
Beta Was this translation helpful? Give feedback.
All reactions