From 3b31a83ac5ca5dbcfbce75454e1193762becbc47 Mon Sep 17 00:00:00 2001 From: milos-dukic Date: Mon, 15 Sep 2025 15:21:04 +0200 Subject: [PATCH 1/2] [ServiceWorler fix] - Failed to get a ServiceWorkerRegistration error. --- app/javascript/controllers/notifications_controller.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/javascript/controllers/notifications_controller.js b/app/javascript/controllers/notifications_controller.js index 1913c0e..e585f70 100644 --- a/app/javascript/controllers/notifications_controller.js +++ b/app/javascript/controllers/notifications_controller.js @@ -60,7 +60,8 @@ export default class extends Controller { } get #serviceWorkerRegistration() { - return navigator.serviceWorker.getRegistration(window.location.host) + const hostAndProtocol = window.location.protocol + '//' + window.location.host; + return navigator.serviceWorker.getRegistration(hostAndProtocol) } #registerServiceWorker() { From 10569b57a36f2cecdeb21f886c2830d39082cb23 Mon Sep 17 00:00:00 2001 From: Milos Dukic <97025173+milos-dukic@users.noreply.github.com> Date: Mon, 15 Sep 2025 16:24:27 +0200 Subject: [PATCH 2/2] Update app/javascript/controllers/notifications_controller.js Co-authored-by: Chris Oliver --- app/javascript/controllers/notifications_controller.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/javascript/controllers/notifications_controller.js b/app/javascript/controllers/notifications_controller.js index e585f70..3ce53a5 100644 --- a/app/javascript/controllers/notifications_controller.js +++ b/app/javascript/controllers/notifications_controller.js @@ -60,8 +60,7 @@ export default class extends Controller { } get #serviceWorkerRegistration() { - const hostAndProtocol = window.location.protocol + '//' + window.location.host; - return navigator.serviceWorker.getRegistration(hostAndProtocol) + return navigator.serviceWorker.getRegistration(window.location.origin) } #registerServiceWorker() {