WASM redirección al index del proyecto en lugar del index de la librería al publicar en servidor

Utilizando la librería PDF.js Express Viewer el archivo services-worker.published.js redirecciona al index del proyecto en lugar del index de la librería, la cual se ubica en root. Para solucionar el problema se debe de incluir el seguinte código

async function onFetch(event) {
let cachedResponse = null;
if (event.request.method === ‘GET’) {
// For all navigation requests, try to serve index.html from cache,
// unless that request is for an offline resource.
// If you need some URLs to be server-rendered, edit the following check to exclude those URLs
const shouldServeIndexHtml = event.request.mode === ‘navigate’
&& !manifestUrlList.some(url => url === event.request.url)
&& !event.request.url.includes(‘/lib/ui/index’);

    const request = shouldServeIndexHtml ? 'index.html' : event.request;
    const cache = await caches.open(cacheName);
    cachedResponse = await cache.match(request);

return cachedResponse || fetch(event.request);


Hello dmedina,

Thank you for raising this, Im not sure what is going on here, can you provide any error logs or a sample project to reproduce this issue?

Best regards,

Hi Tyler

I attached the link to a similar problem. I don’t have an example to share.

Blazor WASM PWA not returning static files from wwwroot on first request after publish due to service worker cache · Issue #39592 · dotnet/aspnetcore · GitHub

From what I understood, it’s a redirection issue.

Best regards