Основной код сценария:
Код: Выделить всё
navigator.serviceWorker.register('sw.js');
Код: Выделить всё
console.log("I'm a service worker");
Код: Выделить всё
An unknown error occurred when fetching the script.
Failed to load resource: net::ERR_CONNECTION_REFUSED
localhost/:1 Uncaught (in promise) TypeError: Failed to register a ServiceWorker: An unknown error occurred when fetching the script.
Код: Выделить всё
I'm a service worker
Код:
Код: Выделить всё
fetch("https://localhost:4634/sw.js", {
"credentials":"omit",
"headers": {},
"referrer":"https://localhost:4634/sw.js",
"referrerPolicy":"no-referrer-when-downgrade",
"body":null,
"method":"GET",
"mode":"cors"
}).then(res => {
return res.text();
}).then(text => {
console.log(text);
});
Код: Выделить всё
console.log("I'm a service worker");
Подробнее здесь: https://stackoverflow.com/questions/516 ... on-refused