0

I'm trying to register a simple web worker it's failing everytime. The console sends this error :

Uncaught (in promise) TypeError: Failed to register a ServiceWorker: The URL protocol of the current origin ('null') is not supported.

This is my JS code at a file named "index.js":

if ('serviceWorker' in navigator) {
    navigator.serviceWorker.register('worker.js').then(reg => console.log("Succeed"))
};

woker.js and index.js are in the same folder, and index.js is the file that is linked to the HTML file. Iv'e been trying to follow every guide on youtube and looked for every guide on google and still no one solved my problem...

SahiBalata
  • 313
  • 2
  • 5
  • 13
  • Is your file named ```worker.js``` or ```worker.js```? – Chif Oct 11 '19 at 08:36
  • This issue was answered here: https://stackoverflow.com/a/39136817/11854340 – Chif Oct 11 '19 at 08:38
  • Possible duplicate of [Service Worker Registration Failed](https://stackoverflow.com/questions/39136625/service-worker-registration-failed) – Chif Oct 11 '19 at 08:39

0 Answers0