Rails: Report CSP Violations to Sentry

Posted . Visible to the public.

You can report CSP violations to Sentry.

Within config/initializers/content_security_policy.rb:

Rails.application.configure do
  config.content_security_policy do |policy|
    # Settings for the policy

    policy.report_uri 'https://ooo4444bbb.ingest.de.sentry.io/api/ooo4444bbb/security/?sentry_key=ooo4444bbb'
  end
end

Replace the actual report_uri with the one from your project settings under https://makandra-eu.sentry.io/settings/projects//security-headers/ Show archive.org snapshot . Replace <project-name> with the actual name of the project.

Or navigate to it via the UI: Open your project -> Settings -> Within the Section "SDK Setup" click "Security Header".

Felix Eschey
Last edit
Felix Eschey
License
Source code in this card is licensed under the MIT License.
Posted by Felix Eschey to makandra dev (2025-06-26 10:07)