I've now written my first Blazor web assembly app and I ran into a few issues after I got it running on the server as a PWA. The first load of the app would work but subsequent loads would fail with a
Uncaught SyntaxError: Unexpected token '<' error (because
What fixed the issue for me was updating the
shouldServeIndexHtml variable so that it only did so on a request to
const shouldServeIndexHtml = event.request.mode === 'navigate' && new URL(event.request.url).pathname === '/';
It should be noted that this fix might break offline functionality something that was not an issue for my use cases.