-
Notifications
You must be signed in to change notification settings - Fork 49
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
Using (multiple) subdomains; change base URL like Cypress’ Config API (ish) …? #45
Comments
Hey thanks for posting this. I haven't gotten a chance to formulate a response yet because issues of domain-level routing logic are complex enough (is it client-side or server-side routing? what kind of request is being made to the domain?) that it's not super clear what fixes I could propose that would fix you. Can you try to reproduce the scenario you're describing in a minimal repo for me to look at? |
@cabgfx don't you just need to boot it on |
Seems possible, @yagudaev and thanks for that! Just so I'm clear, does And thanks @searls I'll try to elaborate with a repo to show my issue. Rails.application.routes.draw do
def subdomain_for(env_var)
# in development, I have eg. subdomain1.myapp.test (using puma-dev),
# so when I use subdomain1.lvh.me in specs,
# the lvh.me domain points back to localhost
# and Rails will match subdomain1 or subdomain2, with these constraints below
ActionDispatch::Http::URL.extract_subdomain(ENV[env_var], 1)
end
constraints subdomain: subdomain_for("PreshopDomain") do
# app routing
end
constraints subdomain: subdomain_for("WebshopDomain") do
# app routing
end
constraints subdomain: "" do
get "/", to: redirect(domain: ENV["WebshopDomain"])
end
end |
Yeah I did mean the puma server on 0.0.0.0. What was the 500 error in the server logs? |
First of all, thank you for putting this out in the world 🙏
What I'm trying to do:
Run specs across two different subdomains, eg.
My app has two routing constraints, based on subdomain. They are distinct parts of the app, ie. different controllers, views, etc. Somewhat similar to multi-tenancy, or admin/public namespaced apps, so I'd suspect this use case of testing across subdomains might come up for others?
What I've tried:
I've tried this option , continuing from the example above:
The base URL is changed alright, but Cypress isn't going anywhere, since Puma was booted on default 127.0.0.1.
(To be clear, the spec runs correctly whenever
ENV['CYPRESS_RAILS_HOST']
matchesconfig.baseUrl
.)Where I'm stuck:
ENV['CYPRESS_RAILS_HOST']
the only way to setconfig.host
? I realize this gem says on the tin, “The cypress-rails gem is configured entirely via environment variables.”, so I could see how it would be?baseUrl
?Thanks in advance for considering my issue!
Background/paper trail:
CYPRESS_RAILS_HOST
andbaseUrl
, omitting one, the other, then both, etc. 👯♂️visit
‘s in one exampleAlso, I've seen #25 and its follow-up #26 — seems related? You mention this in a closing remark:
Is that similar to my issue here?
The text was updated successfully, but these errors were encountered: