From 99382db7203f1598c27d71b612a75230cc8b83b6 Mon Sep 17 00:00:00 2001 From: Rosa Gutierrez Date: Fri, 20 Feb 2026 12:43:18 +0100 Subject: [PATCH] Only start offline mode when signed in Gate Turbo.offline.start() behind Current.user so the service worker is only registered for authenticated users. This avoids errors on unauthenticated pages where /service-worker.js requires auth. Co-Authored-By: Claude Opus 4.6 --- app/javascript/initializers/offline.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/javascript/initializers/offline.js b/app/javascript/initializers/offline.js index 446a9671e..877ffa0ef 100644 --- a/app/javascript/initializers/offline.js +++ b/app/javascript/initializers/offline.js @@ -1,7 +1,9 @@ import { Turbo } from "@hotwired/turbo-rails" -Turbo.offline.start("/service-worker.js", { - scope: "/", - native: true, - preload: /\/assets\// -}) +if (Current.user) { + Turbo.offline.start("/service-worker.js", { + scope: "/", + native: true, + preload: /\/assets\// + }) +}