1
0

1_hosts.rb 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # frozen_string_literal: true
  2. port = ENV.fetch('PORT') { 3000 }
  3. host = ENV.fetch('LOCAL_DOMAIN') { "localhost:#{port}" }
  4. web_host = ENV.fetch('WEB_DOMAIN') { host }
  5. alternate_domains = ENV.fetch('ALTERNATE_DOMAINS') { '' }.split(/\s*,\s*/)
  6. Rails.application.configure do
  7. https = Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'
  8. config.x.local_domain = host
  9. config.x.web_domain = web_host
  10. config.x.use_https = https
  11. config.x.use_s3 = ENV['S3_ENABLED'] == 'true'
  12. config.x.use_swift = ENV['SWIFT_ENABLED'] == 'true'
  13. config.x.alternate_domains = alternate_domains
  14. config.action_mailer.default_url_options = { host: web_host, protocol: https ? 'https://' : 'http://', trailing_slash: false }
  15. config.x.streaming_api_base_url = ENV.fetch('STREAMING_API_BASE_URL') do
  16. if Rails.env.production?
  17. "ws#{https ? 's' : ''}://#{web_host}"
  18. else
  19. "ws://#{ENV['REMOTE_DEV'] == 'true' ? host.split(':').first : 'localhost'}:4000"
  20. end
  21. end
  22. unless Rails.env.test?
  23. config.hosts << host if host.present?
  24. config.hosts << web_host if web_host.present?
  25. config.hosts.concat(alternate_domains) if alternate_domains.present?
  26. config.host_authorization = { exclude: ->(request) { request.path == '/health' } }
  27. end
  28. end