Open svoop opened 9 months ago
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 7-2-stable
branch or on main
, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.
Nothing has changed, still a problem.
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 7-2-stable
branch or on main
, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.
Keepalive, pls
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 8-0-stable
branch or on main
, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.
Ping!
Steps to reproduce
The following line of code may (under rare conditions) cause problems:
https://github.com/rails/rails/blob/44db6bbfcbe66ac5926f01f3b693a378552b752f/actionpack/lib/action_dispatch/routing/route_set.rb#L888
This mock request works fine for most Rails apps, however, if the app handles multiple domains and contains domain specific constraints, things go kaboom. Say you have a constraint like this one:
(Things such a
DomainsController
might do: Redirect "www.myservice.com" to "myservice.com" or redirect shortcuts such as "yourproject.myservice.com" to "myservice.com/yourproject".)With such an entry in
routes.rb
, the mock request misbehaves because it is only fed with thepath
and therefore uses the hardcoded fallback server name "example.org". And since"example.org" != "myservice.com"
, the remainder ofrecognize_path
works off the wrong route.The solution is quite simple, something along the lines of:
By passing the real URL instead of just the path, the mock request no longer uses the fallback but hits the router as a real request would.
I'll work around this for now and take a look at the corresponding tests to check whether I can solder together a PR.
System configuration
Rails version: 6.1.7.6 (but the code hasn't changed on
main
as of today)Ruby version: 3.1.4