File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,15 +28,17 @@ def initialize(app)
2828 @app = app
2929 end
3030
31- SIDEKIQ_CSP = "default-src 'self'; img-src 'self' data:; " \
32- "style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'" . freeze
33-
3431 def call ( env )
32+ # Capture path before @app.call — Rails mutates PATH_INFO during routing
33+ path = env [ 'PATH_INFO' ]
3534 status , headers , body = @app . call ( env )
3635
37- if env [ 'PATH_INFO' ] . start_with? ( '/sidekiq' )
36+ if path . start_with? ( '/sidekiq' )
37+ # Rack 3 normalises header keys to lowercase; delete both variants to be safe.
38+ # Sidekiq::Web already injects its own permissive CSP with nonce, so we just
39+ # remove the restrictive one added by ActionDispatch / our own HEADERS hash.
3840 headers . delete ( 'Content-Security-Policy' )
39- headers [ 'Content-Security-Policy' ] = SIDEKIQ_CSP
41+ headers . delete ( 'content-security-policy' )
4042 return [ status , headers , body ]
4143 end
4244
You can’t perform that action at this time.
0 commit comments