2

I understand that in order to register a Service Worker in a directory other than "/" (wwwroot in Blazor Server) I need to:

1) Add the scope to the registration:

navigator.serviceWorker.register('/static/mod/practice/service-worker.js', { scope: '/' })
    .then(function (registration)
    {
      console.log('Service worker registered successfully');
    }).catch(function (e)
    {
      console.error('Error during service worker registration:', e);
    });

(Source Understanding Service Worker scope)

2) Add http header Service-Worker-Allowed (Source Understanding Service Worker scope and https://w3c.github.io/ServiceWorker/#service-worker-script-response)

Question: How can I add the Service-Worker-Allowed header in a Blazor Server project?

Gruber
  • 21
  • 1

0 Answers0