content_security_policy.rb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # frozen_string_literal: true
  2. # Be sure to restart your server when you modify this file.
  3. # Define an application-wide content security policy
  4. # For further information see the following documentation
  5. # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
  6. # Rails.application.config.content_security_policy do |policy|
  7. # policy.default_src :self, :https
  8. # policy.font_src :self, :https, :data
  9. # policy.img_src :self, :https, :data
  10. # policy.object_src :none
  11. # policy.script_src :self, :https
  12. # policy.style_src :self, :https
  13. # If you are using webpack-dev-server then specify webpack-dev-server host
  14. # if Rails.env.development?
  15. # policy.connect_src(
  16. # :self,
  17. # :https,
  18. # 'http://localhost:3035',
  19. # 'ws://localhost:3035',
  20. # )
  21. # end
  22. # # Specify URI for violation reports
  23. # # policy.report_uri "/csp-violation-report-endpoint"
  24. # end
  25. # If you are using UJS then enable automatic nonce generation
  26. Rails.application.config.content_security_policy_nonce_generator =
  27. ->(_request) { SecureRandom.base64(16) }
  28. # Report CSP violations to a specified URI
  29. # For further information see the following documentation:
  30. # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
  31. # Rails.application.config.content_security_policy_report_only = true