diff --git a/app/controllers/pwa_controller.rb b/app/controllers/pwa_controller.rb index 841c8e921..bd6127182 100644 --- a/app/controllers/pwa_controller.rb +++ b/app/controllers/pwa_controller.rb @@ -1,12 +1,8 @@ class PwaController < ApplicationController - allow_unauthenticated_access + require_untenanted_access skip_forgery_protection # We need a stable URL at the root, so we can't use the regular asset path here. def service_worker end - - # Need ERB interpolation for paths, so can't use asset path here either. - def manifest - end -end \ No newline at end of file +end diff --git a/app/javascript/controllers/notifications.js b/app/javascript/controllers/notifications_controller.js similarity index 97% rename from app/javascript/controllers/notifications.js rename to app/javascript/controllers/notifications_controller.js index 49fcc7f5a..87832326c 100644 --- a/app/javascript/controllers/notifications.js +++ b/app/javascript/controllers/notifications_controller.js @@ -57,7 +57,8 @@ export default class extends Controller { } #registerServiceWorker() { - return navigator.serviceWorker.register("/service-worker.js") + // Use absolute path to register from root, regardless of current account scope + return navigator.serviceWorker.register("/service-worker.js", { scope: "/" }) } async #subscribe(registration) { diff --git a/config/routes.rb b/config/routes.rb index 2813c8dea..cc23438c4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -170,7 +170,7 @@ Rails.application.routes.draw do end get "up", to: "rails/health#show", as: :rails_health_check - get "manifest" => "pwa#manifest", as: :pwa_manifest + get "manifest" => "rails/pwa#manifest", as: :pwa_manifest get "service-worker" => "pwa#service_worker" root "events#index"