flow icon indicating copy to clipboard operation
flow copied to clipboard

Service worker does not work correctly in combination with frontend views and servlet mapping

Open mcollovati opened this issue 1 year ago • 0 comments

Description of the bug

If a Vaadin application is served on a nested path (e.g. /nested/* custom servlet mapping with also /VAADIN/* mapped), service worker is not able to handle frontend view when browser is offline.

Service worker javascript resources is served at /contextPath/nested/sw.js and it seems like it is configured to handle request under /contextPath/nested/. When switching to offline mode and clicking on a link handled by Vaadin Router the requested path is like /contextPath/VAADIN/views/myview/myview and it is not served by service worker.

Minimal reproducible example

Run ServiceWorkerOnNestedMappingIT from flow-tests/test-ccdm-flow-navigation with Vite enabled. Tests works fine with Webpack.

Expected behavior

Frontend view is accessible even offline. Test defined in ServiceWorkerOnNestedMappingIT pass.

Actual behavior

When offline the request for the frontend view is not handled by service worker. Test defined in ServiceWorkerOnNestedMappingIT fail.

Versions:

- Vaadin / Flow version: 23.2
- Java version: 11
- Development mode:
- Existing test in Flow code base

mcollovati avatar Jul 28 '22 08:07 mcollovati