Skip to content
Prev Previous commit
Next Next commit
Remove non-lowercase headers in Rails default configuration (fixes #541)
While this gem now uses lowercase headers, the Rails default configuration still
defines non-lowercase headers.  As a result, our Railtie will not remove those
conflicting headers.

This change ensures that we're accounting for both lowercase and non-lowercase
default headers in Rails.
  • Loading branch information
obrie authored and denn-os committed Dec 17, 2025
commit 9bc0b6c805b342ef38fc0ca6d0a3f6d99214937f
9 changes: 6 additions & 3 deletions lib/secure_headers/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ class Railtie < Rails::Railtie
ActiveSupport.on_load(:action_controller) do
include SecureHeaders

unless Rails.application.config.action_dispatch.default_headers.nil?
conflicting_headers.each do |header|
Rails.application.config.action_dispatch.default_headers.delete(header)
default_headers = Rails.application.config.action_dispatch.default_headers
unless default_headers.nil?
default_headers.each_key do |header|
if conflicting_headers.include?(header.downcase)
default_headers.delete(header)
end
end
end
end
Expand Down