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 <noreply@anthropic.com>
This commit is contained in:
Rosa Gutierrez
2026-02-20 12:43:18 +01:00
parent 0482670fec
commit 99382db720
+7 -5
View File
@@ -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\//
})
}