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

Remove URL setting #5000

Merged
merged 3 commits into from
Oct 4, 2022
Merged

Remove URL setting #5000

merged 3 commits into from
Oct 4, 2022

Conversation

javierm
Copy link
Member

@javierm javierm commented Oct 3, 2022

References

Backgrounds

Until now, CONSUL installations had to specify their domain in two places: the server_name key in the secrets.yml file (which is done automatically by the installer) and the url configuration option in the administration settings.

This was redundant and, since the url option was only used when generating the sitemap, the dev_seeds, a <meta> tag and to validate related content, it was perfectly possible to leave it at the default value of example.com and never realize some things weren't working properly.

Furthermore, validating the related content and generating the mentioned <meta> tag is done in the context of a request, so we already have the domain in the request itself and don't need a configuration option.

Objectives

  • Simplify code dealing with absolute URLs in the context of a request
  • Have only one setting to specify the main URL of the application
  • Make it easier to deal with different hosts when adding multitenancy

Release Notes

We've removed the url configuration option in the administration settings. If you're using Setting["url"] in your custom code, replace it with either root_url (if the code is executed during a request) or with root_url(ActionMailer::Base.default_url_options) (if the code is executed during a rake task or a delayed job).

We were using `Setting["url"]` to verify the content belonged to the
application URL, but we can use `root_url` instead.

Note that means we need to include the port when filling in forms in the
tests, since in tests URL helpers like `polymorphic_url` don't include
the port, but a port is automatically added when actually making the
request.
We've been using the `url` Setting for a long time, but since then we've
added a few references to `root_url` to this file, so we're now adding
consistency. We're also removing a now unnecessary condition.
In the dev seeds, we were using `Setting["url"]/proposals`, but we can
use `proposals_url` instead, similar to what we do in the rest of the
application.

We can do a similar thing in the sitemap. This way the sitemap will also
work on installations who haven't manually set the "url" setting.

Since we aren't using `Setting["url"]` anywhere anymore, we're removing
it.

This setting was mainly redundant, since we already had the
`server_name` in the secrets. Furthermore, `server_name` is
automatically configured when running the installer, while
`Setting["url"]` had to be manually set in the admin section the
application was installed.

Note we're using `ActionMailer::Base` setting to generate URLs. Sounds a
bit strange, but it's a standard way Rails provides to generate URLs
outside the context of a request.
@javierm javierm self-assigned this Oct 3, 2022
@javierm javierm added this to Reviewing in Consul Democracy Oct 3, 2022
@taitus taitus self-assigned this Oct 4, 2022
Base automatically changed from unused_tasks to master October 4, 2022 12:36
Consul Democracy automation moved this from Reviewing to Testing Oct 4, 2022
@javierm javierm merged commit 3e72635 into master Oct 4, 2022
Consul Democracy automation moved this from Testing to Release 1.6.0 Oct 4, 2022
@javierm javierm deleted the remove_setting_url branch October 4, 2022 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants