Fix routes to manifest and service-worker, rename controller

This commit is contained in:
Jason Zimdars
2025-07-15 16:42:47 -05:00
parent 8f47db3ced
commit 47324eb45a
3 changed files with 5 additions and 8 deletions
+2 -6
View File
@@ -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
end
@@ -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) {
+1 -1
View File
@@ -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"