comfy / comfortable-mexican-sofa

ComfortableMexicanSofa is a powerful Ruby on Rails 5.2+ CMS (Content Management System) Engine
MIT License
2.72k stars 637 forks source link

Documentation on Hostname Aliases Unclear #919

Open robyurkowski opened 4 years ago

robyurkowski commented 4 years ago

Note: For general questions and feature requests please leave a message on Gitter: https://gitter.im/comfy/comfortable-mexican-sofa

Expected behavior

Based on the documentation included in config/initializers/comfortable_mexican_sofa.rb...

  # Site aliases, if you want to have aliases for your site. Good for harmonizing
  # production env with dev/testing envs.
  # e.g. config.hostname_aliases = {'host.com' => 'host.inv', 'host_a.com' => ['host.lvh.me', 'host.dev']}
  # Default is nil (not used)

... there's no mention of needing to include the port with host aliases.

So it appears at first glance that if you:

  1. Create a site with host myhost.com, a layout, and a basic page;
  2. Change config.hostname_aliases = { "myhost.com" => "myhost.lvh.me" };
  3. Reload the server;
  4. Visit myhost.lvh.me

You should be served that basic page for myhost.com.

Actual behavior

However, if you're running in the standard Rails dev mode and serving off of port 3000, site lookup fails.

Steps to reproduce

This line in BaseController.rb:

::Comfy::Cms::Site.find_site(request.host_with_port.downcase, request.fullpath)

... shows that the port is taken into consideration.

I'm happy to make a patch to improve the documentation in the initializer, but I wanted to check that you want to consider the port first.

System configuration

Rails version: 6.0

CMS version: 2.0.19

Ruby version: 2.6