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:
@@ -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\//
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user