Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Allow PWA assets without forgery checks

sure-adminf4ace1217711
diff --git a/app/controllers/pwa_controller.rb b/app/controllers/pwa_controller.rb
index 46c949e121..287936efc1 100644
--- a/app/controllers/pwa_controller.rb
+++ b/app/controllers/pwa_controller.rb
@@ -1,5 +1,6 @@
class PwaController < ApplicationController
skip_authentication
+ skip_forgery_protection
def manifest
# Force JSON format to avoid MissingTemplate errors when browsers request /manifest
diff --git a/test/controllers/pwa_controller_test.rb b/test/controllers/pwa_controller_test.rb
index b7b18ce5a1..a82244df5e 100644
--- a/test/controllers/pwa_controller_test.rb
+++ b/test/controllers/pwa_controller_test.rb
@@ -8,4 +8,15 @@ class PwaControllerTest < ActionDispatch::IntegrationTest
assert_equal "application/manifest+json", response.media_type
assert_includes response.body, '"start_url": "/"'
end
+
+ test "service worker responds successfully without origin or referer headers" do
+ get "/service-worker", headers: {
+ "Accept" => "*/*",
+ "DNT" => "1",
+ "Sec-GPC" => "1"
+ }
+
+ assert_response :success
+ assert_equal "application/javascript", response.media_type
+ end
end