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

Support relative_url_root #702

Open
andyundso opened this issue May 16, 2024 · 0 comments
Open

Support relative_url_root #702

andyundso opened this issue May 16, 2024 · 0 comments

Comments

@andyundso
Copy link
Contributor

Feature Request

Is your feature request related to a problem?

yes and no. we have a Rails application which can run under a relative root url, configured with ActionController::Base.config.relative_url_root. what we noted is:

  • the reflex is sent with the full path, including the value configured in config.relative_url_root.
  • StimulusReflex is then unable to resolve the corresponding controller and action.

we had to adjust config.ru to make the relative root url work (prior to adding StimulusReflex)

# This file is used by Rack-based servers to start the application.

require_relative "config/environment"

map ActionController::Base.config.relative_url_root || "/" do
  run Rails.application
end

Rails.application.load_server

currently we use a small monkey-patch to make it work with StimulusReflex.

class StimulusReflex::ReflexData
  def url
    url = data[:url].to_s

    if ActionController::Base.config.relative_url_root
      url.gsub(ActionController::Base.config.relative_url_root, "")
    else
      url
    end
  end
end

Describe the solution you'd like

would be nice if relative_root_url is considered by StimulusReflex.

Additional context

nothing really to add

PR link

happy to send a PR if the monkey-patch is good enough :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant