Uncaught (in promise) TypeError: Failed to execute 'addAll' on 'Cache': Request failed
serviceworker.js:1
Above is the error from my dev tools console upon launching a django progressive web app. Below is my full serviceworker.js file
var staticCacheName = 'djangopwa-v1';
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open(staticCacheName).then(function(cache) {
return cache.addAll([
'/index',
]);
})
);
});
self.addEventListener('fetch', function(event) {
var requestUrl = new URL(event.request.url);
if (requestUrl.origin === location.origin) {
if ((requestUrl.pathname === '/')) {
event.respondWith(caches.match('/index'));
return;
}
}
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
});
I tried keeping cache.addAll empty but I still get the same error. I have not put in any offline support because I do not intend to use the app offline. I want to fix this but these posts were not helpful Uncaught (in promise) TypeError: Failed to execute 'Cache' on 'addAll': Request failed on progressive web app and Django - ServiceWorker, Uncaught (in promise) TypeError: Failed to execute 'addAll' on 'Cache': Request failed
I got the serviceworker.js from https://www.geeksforgeeks.org/make-pwa-of-a-django-project/ and it throws the same error.