Skip to content

Commit 6260b6b

Browse files
authored
Allow .test by default in development (rails#51087)
This ensures out-of-the-box compatibility with puma-dev
1 parent 270eaa0 commit 6260b6b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

actionpack/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Add ".test" as a default allowed host in development to ensure smooth golden-path setup with puma.dev.
2+
3+
*DHH*
4+
15
* Add `allow_browser` to set minimum browser versions for the application.
26

37
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".

actionpack/lib/action_dispatch/middleware/host_authorization.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module ActionDispatch
2020
# info if `config.consider_all_requests_local` is set to true, otherwise the
2121
# body is empty.
2222
class HostAuthorization
23-
ALLOWED_HOSTS_IN_DEVELOPMENT = [".localhost", IPAddr.new("0.0.0.0/0"), IPAddr.new("::/0")]
23+
ALLOWED_HOSTS_IN_DEVELOPMENT = [".localhost", ".test", IPAddr.new("0.0.0.0/0"), IPAddr.new("::/0")]
2424
PORT_REGEX = /(?::\d+)/ # :nodoc:
2525
SUBDOMAIN_REGEX = /(?:[a-z0-9-]+\.)/i # :nodoc:
2626
IPV4_HOSTNAME = /(?<host>\d+\.\d+\.\d+\.\d+)#{PORT_REGEX}?/ # :nodoc:

railties/test/application/configuration_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3997,6 +3997,11 @@ class Post < ActiveRecord::Base
39973997
assert_includes Rails.application.config.hosts, ".localhost"
39983998
end
39993999

4000+
test "hosts include .test in development" do
4001+
app "development"
4002+
assert_includes Rails.application.config.hosts, ".test"
4003+
end
4004+
40004005
test "hosts reads multiple values from RAILS_DEVELOPMENT_HOSTS" do
40014006
host = "agoodhost.com"
40024007
another_host = "bananapants.com"

0 commit comments

Comments
 (0)