Allow .test by default in development (#51087)

This ensures out-of-the-box compatibility with puma-dev
This commit is contained in:
David Heinemeier Hansson 2024-02-14 08:28:25 -08:00 committed by GitHub
parent 270eaa0565
commit 6260b6b0c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,7 @@
* Add ".test" as a default allowed host in development to ensure smooth golden-path setup with puma.dev.
*DHH*
* Add `allow_browser` to set minimum browser versions for the application.
A browser that's blocked will by default be served the file in `public/426.html` with a HTTP status code of "426 Upgrade Required".

View File

@ -20,7 +20,7 @@ module ActionDispatch
# info if `config.consider_all_requests_local` is set to true, otherwise the
# body is empty.
class HostAuthorization
ALLOWED_HOSTS_IN_DEVELOPMENT = [".localhost", IPAddr.new("0.0.0.0/0"), IPAddr.new("::/0")]
ALLOWED_HOSTS_IN_DEVELOPMENT = [".localhost", ".test", IPAddr.new("0.0.0.0/0"), IPAddr.new("::/0")]
PORT_REGEX = /(?::\d+)/ # :nodoc:
SUBDOMAIN_REGEX = /(?:[a-z0-9-]+\.)/i # :nodoc:
IPV4_HOSTNAME = /(?<host>\d+\.\d+\.\d+\.\d+)#{PORT_REGEX}?/ # :nodoc:

View File

@ -3997,6 +3997,11 @@ module ApplicationTests
assert_includes Rails.application.config.hosts, ".localhost"
end
test "hosts include .test in development" do
app "development"
assert_includes Rails.application.config.hosts, ".test"
end
test "hosts reads multiple values from RAILS_DEVELOPMENT_HOSTS" do
host = "agoodhost.com"
another_host = "bananapants.com"