Skip to content

Commit 7edcbdd

Browse files
committed
Update host of development environment
1 parent 9a54980 commit 7edcbdd

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

app/swagger_docs/swagger_docs.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class SwaggerDocs
4040
end
4141

4242
server do
43-
key :url, (Rails.env.development? ? 'http://localhost:3000' : 'https://api.rails.boilerplate').to_s
43+
url_options = Rails.application.routes.default_url_options
44+
key :url, "#{url_options[:protocol]}://#{url_options[:host]}"
4445
key :description, 'Rails API Boilerplate'
4546
end
4647
end

bin/dev

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ then
66
gem install foreman
77
fi
88

9-
foreman start -f Procfile.dev "$@"
9+
foreman start -p 3000 -f Procfile.dev "$@"

config/environments/development.rb

+8
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22

33
require 'active_support/core_ext/integer/time'
44

5+
APP_HOST = "lvh.me:#{ENV.fetch('PORT', 3000)}".freeze
6+
URL_PROTOCOL = ENV['URL_PROTOCOL'] || 'http'
7+
8+
Rails.application.routes.default_url_options[:host] = APP_HOST
9+
Rails.application.routes.default_url_options[:protocol] = URL_PROTOCOL
10+
511
Rails.application.configure do
612
# Settings specified here will take precedence over those in config/application.rb.
713

14+
config.hosts << '.lvh.me'
15+
816
# In the development environment your application's code is reloaded any time
917
# it changes. This slows down response time but is perfect for development
1018
# since you don't have to restart the web server when you make code changes.

0 commit comments

Comments
 (0)