Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace /etc/hosts change with RFC6761 localhost #1047

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def whitelabel_javascript_include_tag
end

def label_auth_url(provider)
host = Rails.env.development? ? "http://#{Whitelabel[:label_id]}.onruby.test:3000" : Whitelabel[:canonical_url]
host = Rails.env.development? ? "http://#{Whitelabel[:label_id]}.onruby.localhost:3000" : Whitelabel[:canonical_url]

"#{host}/auth/#{provider}?origin=#{CGI.escape(params[:origin]) if params[:origin]}"
end

def label_url(label)
host = Rails.env.development? ? "#{label.label_id}.onruby.test" : label.canonical_url
host = Rails.env.development? ? "#{label.label_id}.onruby.localhost" : label.canonical_url
root_url(host:)
end

Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
config.hosts << /.*onruby\.test.*/
config.hosts << /.*onruby\.localhost.*/

# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for development
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/data.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace :data do
5.times { FactoryBot.create(:event, date: rand(100).days.ago) }
5.times { FactoryBot.create(:participant) }
end
puts 'now open your browser at http://hamburg.onruby.test:3000/'
puts 'now open your browser at http://hamburg.onruby.localhost:3000/'
end

task setup: ['environment', 'db:migrate'] do
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/fork.rake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ namespace :fork do
FileUtils.mkdir_p(Rails.root.join("app/assets/javascripts/labels/#{usergroup.label_id}"))
FileUtils.touch(Rails.root.join("app/assets/javascripts/labels/#{usergroup.label_id}/.gitkeep"))

puts "now add '127.0.0.1 #{name}.onruby.test' to your /etc/hosts, run 'script/server' and run 'open #{name}.onruby.test:3000'"
puts "now add '127.0.0.1 #{name}.onruby.localhost' to your /etc/hosts, run 'script/server' and run 'open #{name}.onruby.localhost:3000'"
end
end
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ script/in_docker bundle exec rspec spec/requests/labels_spec.rb

#### Add usergroup hostnames to `/etc/hosts`

Note: This step is currently only necessary for Safari, all other browsers thread localhost as wildcard domain.

Add all supported subdomains to your `/etc/hosts` file:

```
127.0.0.1 www.onruby.test hamburg.onruby.test cologne.onruby.test berlin.onruby.test madridrb.onruby.test andalucia.onruby.test
127.0.0.1 www.onruby.test hamburg.onruby.localhost cologne.onruby.localhost berlin.onruby.localhost madridrb.onruby.localhost andalucia.onruby.localhost
```

#### Visit the site
Expand Down
Loading