service-workerprogressive-web-appsprogressive

PWA (Uncaught (in promise) TypeError: Request failed) error


this is my code I don't understand where this error is coming from i have tired methods from provious post but this doesnt seem to work. pls help thanks in advance.

this is the error

this is my service worker code


Solution

  • This happens due to a failure when calling cache.addAll with paths that don't exist on the server the SW is making its requests to. You have to be very careful with the paths.

    What would probably fix your problem is prepending a slash (/) to all your asset paths (eg. main.js -> /main.js). This is, of course, pure guessing since I don't really know what files are sitting on your server.

    If you remove all of them (comment out for example) and add back to the cacheAssets array one by one you will see which causes the problem =)