Skip to content

Commit

Permalink
Allow .test by default in development (rails#51087)
Browse files Browse the repository at this point in the history
This ensures out-of-the-box compatibility with puma-dev
  • Loading branch information
dhh authored and Ridhwana committed Mar 5, 2024
1 parent 6c1606e commit f5f2dbf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions actionpack/CHANGELOG.md
@@ -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".
Expand Down
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions railties/test/application/configuration_test.rb
Expand Up @@ -3997,6 +3997,11 @@ class Post < ActiveRecord::Base
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"
Expand Down

0 comments on commit f5f2dbf

Please sign in to comment.