From e17d7275f49a7286439d972f01b0fb42331dcdb7 Mon Sep 17 00:00:00 2001 From: Evgeny Vlasenko Date: Tue, 5 Jul 2016 00:36:39 +0600 Subject: Use the HOST environment variable for rails server #25677 --- railties/lib/rails/commands/server.rb | 1 + railties/test/commands/server_test.rb | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index 7418dff18b..f641d9bf2c 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -90,6 +90,7 @@ module Rails def default_options super.merge({ Port: ENV.fetch('PORT', 3000).to_i, + Host: ENV.fetch('HOST', 'localhost').dup, DoNotReverseLookup: true, environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup, daemonize: false, diff --git a/railties/test/commands/server_test.rb b/railties/test/commands/server_test.rb index 38a1605d1f..b9a48bbf98 100644 --- a/railties/test/commands/server_test.rb +++ b/railties/test/commands/server_test.rb @@ -51,6 +51,13 @@ class Rails::ServerTest < ActiveSupport::TestCase end end + def test_environment_with_host + switch_env "HOST", "1.2.3.4" do + server = Rails::Server.new + assert_equal "1.2.3.4", server.options[:Host] + end + end + def test_caching_without_option args = [] options = Rails::Server::Options.new.parse!(args) -- cgit v1.2.3