Skip to content

UrlOptionResolver does not respect documented PORT variable #10231

@alecslupu

Description

@alecslupu

Describe the bug

While investigating the work done by @ahukkanen in #9597, i have noticed that the port of the PR cannot be changed. While investigating further, i came across the below snippet, which uses a wrong ENV variable.

def port
@port ||= begin
default_port =
if Rails.env.development?
3000
elsif Rails.env.test?
Capybara.server_port
elsif Rails.application.config.force_ssl
443
else
80
end
ENV.fetch("HTTP_PORT", default_port).to_i
end
end

As per documentation, the correct variable should be PORT.
Also, if the environment variable, the UrlOptionResolver should rely on the config.action_controller.default_url_options

References:

To Reproduce
Steps to reproduce the behavior:

  1. make sure you are on a branch taht contains the fix for Fix pipeline asset absolute URLs #9597
  2. Open the terminal and type in PORT=3301 bundle exec rails c
  3. in the console type in Decidim::UserPresenter.new(Decidim::User.first).avatar_url
  4. See that the generated port has remained 3000
  5. Repeat steps 2 by using HTTP_PORT=3301 bundle exec rails c
  6. Repeat steps 3, 4 and observe the port has been changed to 3301

Expected behavior
When using the documented variable for PORT, i should be able to change the URL. Also, any rails default way of customizing the URL should work.

Extra data (please complete the following information):

  • Device: [e.g. iPhone6, Desktop]
  • Device OS: [e.g. iOS8.1, Windows 10]
  • Browser: [e.g. Chrome, Firefox, Safari]
  • Decidim Version: [e.g. 0.10]
  • Decidim installation: [e.g. Metadecidim]

Additional context
Add any other context about the problem here. For instance, add Metadecidim link.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions