DEV: Allow custom hosts in development mode

DEV: Allow custom hosts in development mode

Rails 6 seems to introduce a whitelist of allowed hosts. I personally use dev.local for development and this no longer works.

This introduces a new ENV variable, DISCOURSE_DEV_HOST. If present, it will whitelist that host for development mode.

diff --git a/config/environments/development.rb b/config/environments/development.rb
index eb62346..306bd99 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -41,6 +41,7 @@ Discourse::Application.configure do
   BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP']
 
   config.load_mini_profiler = true
+  config.hosts << ENV['DISCOURSE_DEV_HOST'] if ENV['DISCOURSE_DEV_HOST']
 
   require 'middleware/turbo_dev'
   config.middleware.insert 0, Middleware::TurboDev

GitHub sha: 95a9a544

2 Likes

This commit has been mentioned on Discourse Meta. There might be relevant details there:

DEV: support multiple hosts in dev