Open TylerRick opened 5 years ago
Well, adding nonce: true
there didn't work. That results in:
NoMethodError - undefined method `content_security_policy_nonce' for nil:NilClass:
because it tries to delegate to controller
here, and it is nil:
# actionview (5.2.3) lib/action_view/helpers/asset_tag_helper.rb
if tag_options["nonce"] == true
tag_options["nonce"] = content_security_policy_nonce
end
I've used this gem before with success, but I just tried adding it to an app that happens to have a strict CSP and am running into this error:
I wonder if there would be an easy fix to make it work out of the box with strict CSP. Could it be as simple as changing:
lib/xray/middleware.rb:116
:?
I don't know if that helper can access the request's nonce from within a middleware but maybe...
(Otherwise, it could always use a regex to extract the nonce from the
<meta name="csp-nonce"
tag.)As a workaround, I guess I'll have to disable my strict CSP in development, but I'd prefer to keep it strict in development as well so that I ran into any CSP issues sooner...
Reference: