Skip to content

Commit

Permalink
Merge pull request #25688 from mahnunchik/host-env-var
Browse files Browse the repository at this point in the history
Use the HOST environment variable for rails server #25677
  • Loading branch information
guilleiguaran committed Jul 8, 2016
2 parents 48e8056 + e17d727 commit 8e74f71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions railties/lib/rails/commands/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def middleware
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,
Expand Down
7 changes: 7 additions & 0 deletions railties/test/commands/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def test_environment_with_port
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)
Expand Down

0 comments on commit 8e74f71

Please sign in to comment.