0
瀏覽器抱怨該文件是一個重定向背後:如何從春天開機正常服務服務worker.js?
DOMException: Failed to register a ServiceWorker:
The script resource is behind a redirect, which is disallowed.
我試過至今:
Service worker on `static/service-worker.js`
Service worker on @GetMapping("/service-worker.js") @ResponseBody
在這兩種情況下,我可以閱讀從布勞爾文件中/service-worker.js但註冊失敗,同樣的例外。
編輯:(這是註冊我曾與問題)
<script>
if ('serviceWorker' in navigator) {
console.log("Will the service worker register?");
navigator.serviceWorker.register('service-worker.js')
.then(function(reg){
console.log("Yes, it did.");
}).catch(function(err) {
console.log("No it didn't. This happened: ", err)
});
}
</script>