如何更改Blazor中服务人员的范围?

时间:2019-12-03 21:38:36

标签: service-worker blazor

我知道,为了在“ /”(Blazor Server中的wwwroot)以外的目录中注册Service Worker,我需要:

1)将范围添加到注册中:

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);
    });

(来源Understanding Service Worker scope

2)添加http标头Service-Worker-Allowed (来源Understanding Service Worker scopehttps://w3c.github.io/ServiceWorker/#service-worker-script-response

问题:如何在Blazor Server项目中添加Service-Worker-Allowed标头?

0 个答案:

没有答案