From 3927b58e22b3df174472f5df6e5a109685155230 Mon Sep 17 00:00:00 2001 From: Ben Rexin Date: Tue, 6 Aug 2024 23:17:48 +0200 Subject: [PATCH] chore: replace /etc/hosts change with RFC6761 localhost --- app/helpers/application_helper.rb | 4 ++-- config/environments/development.rb | 2 +- lib/tasks/data.rake | 2 +- lib/tasks/fork.rake | 2 +- readme.md | 4 +++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 410af20b5..2ac053949 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/config/environments/development.rb b/config/environments/development.rb index d6fe85bda..6a96b3db9 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -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 diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index d3db056b8..7b1748088 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -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 diff --git a/lib/tasks/fork.rake b/lib/tasks/fork.rake index ecbba2289..ebd907ff9 100644 --- a/lib/tasks/fork.rake +++ b/lib/tasks/fork.rake @@ -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 diff --git a/readme.md b/readme.md index ec3495652..5867e44a3 100644 --- a/readme.md +++ b/readme.md @@ -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