From 9f74cf62f4e140542dce9e09bedb43b324700a00 Mon Sep 17 00:00:00 2001 From: dhh Date: Wed, 14 Feb 2024 08:07:42 -0800 Subject: [PATCH 1/2] Allow .test as a default host in development This ensures out-of-the-box compatibility with puma-dev --- .../lib/action_dispatch/middleware/host_authorization.rb | 2 +- railties/test/application/configuration_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_dispatch/middleware/host_authorization.rb b/actionpack/lib/action_dispatch/middleware/host_authorization.rb index c0a3f79e57fb9..66749cfc1889a 100644 --- a/actionpack/lib/action_dispatch/middleware/host_authorization.rb +++ b/actionpack/lib/action_dispatch/middleware/host_authorization.rb @@ -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 = /(?\d+\.\d+\.\d+\.\d+)#{PORT_REGEX}?/ # :nodoc: diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index f62139db6617d..9b46f3e6d4ef0 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -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" From a775997125a9c5a40d57890b3787575bebdfb703 Mon Sep 17 00:00:00 2001 From: dhh Date: Wed, 14 Feb 2024 08:28:05 -0800 Subject: [PATCH 2/2] Explain change --- actionpack/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 11b54256f8221..96367652f4e7b 100644 --- a/actionpack/CHANGELOG.md +++ b/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".