Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save taketo1113/2c8bc09df58cad318803ab3fd6f24b94 to your computer and use it in GitHub Desktop.
Save taketo1113/2c8bc09df58cad318803ab3fd6f24b94 to your computer and use it in GitHub Desktop.
Rails HostAuthorization setting to Allow any hosts

Rails HostAuthorization setting to Allow any hosts

  • config
Rails.application.config.hosts << /.*/
  • env

    • rails 6.0.3.2
  • works

    • When set regexp to config.hosts, it evaluate as sanitized regexp (ref: method of sanitize_regexp).
# sanitized regexp
host = /.*/
sanitize_regexp(host)
-> /\A(?-mix:.*)\z/

# check to allow host (via: allows?)
allowed = /\A(?-mix:.*)\z/
allowed === 'example.com'
-> true

allowed === 'xxxx.com'
-> true
@silverham
Copy link

PR where the file was added: rails/rails#33145

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment