service worker 在iis下注册范围的设置
注册时,可以设置scope,来超出所在文件夹:
navigator.serviceWorker.register('/scripts/script.js', { scope: '/' })
在web.config中,设置header
<configuration>
<location path="Scripts/script.js">
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Service-Worker-Allowed" value="/" />
</customHeaders>
</httpProtocol>
</system.webServer>
</location>
</configuration>
运行后,不会报Adjust the scope, move the Service Worker script, or use the Service-Worker-Allowed HTTP header to allow the scope.错误

浙公网安备 33010602011771号