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
How to exclude a backend route ? #218
Comments
You can try adding that route to the // vite.config.ts
VitePWA({
// other options
workbox: {
navigateFallbackDenylist: [/^\/backoffice/]
}
}), Previous option will generate this entry on your sw (you must deal with offline support for excluded routes): workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
denylist: [/^\/backoffice/]
})); |
Thanks, this seems to do the trick ! |
This was very helpful, thank you |
yes, very helpful! @userquin may I propose to add a section to docs, like "How to connect pwa to your backend api". I'd guess this is a very common use case for a lot of us, that didn't study workbox docs. I don't remember any situation where I had to configure Thanks for your work! |
@mashpie PR welcome Should also include the option when using custom sw, using the denylist entry on the navigation route. I use it a few days ago on vitest docs to exclude the New action for stackblitz |
@userquin I'd like to, but I am afraid, that my knowledge of assumptions and internals of vite-plugin-pwa is far too limited. Still playing with workbox: {
// navigateFallbackDenylist: [/^\/api/]
runtimeCaching: [
{
handler: 'NetworkFirst',
urlPattern: /^\/api/,
// method: 'POST'
// options: {
// backgroundSync: {
// name: 'myQueueName',
// options: {
// maxRetentionTime: 24 * 60
// }
// }
// }
}
]
} but this never hits my backend... not per GET nor per POST - shouldn't it? |
@mashpie @jlabresh1 @alkanna will be included on the new docs on
EDIT: also included on |
@mashpie sorry for late response, you should include the method, if still not working file an issue on workbox repo, this plugin is just a wrapper for workbox |
I have been successfully using this very basic approach : https://vite-plugin-pwa.netlify.app/guide/generate.html
However, since I have deployed this to production, I have an issue with a route that is supposed to be handled by the load balancer, and then distributed to another service than my SPA.
Currently, if I navigate to /backoffice on my SPA, the service worker seems to be picking up the GET request :
Is there an option to exclude some routes and make then network only ?
I searched a bit on other issues here and found this option, but I don't know if this would be relevant to my case :
The text was updated successfully, but these errors were encountered: