-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: spark routes
shows incorrect hostname routes
#7176
Conversation
I think it should be like this
|
@iRedds I too think all routes should be shown by the command. |
@kenjis It's not just the command. |
@iRedds I don't know a use case that To begin with, I don't really see the need for this limit to host/domain feature itself, which changes the route only for certain hostnames. In what case would it be used? Do you have real use cases? |
The framework allows that one application can serve different domains. Correctly? So it makes sense that this application should be able to generate links to different domains. For example, "our" application consists of several parts. And it is quite possible to use cross-references between the landing page and the private part. Or, for example, we need to generate a url like user.example.com or locale.example.com |
@iRedds Do you have a real use case of multiple domains with different routes in a app? |
I don't have the case you describe. |
I think we need an enhancement or alternative to the
I used it in the SaaS app. Very handful.
There was a demand from developers for this. Personally, I think this is quite a common "problem" - a lot of services use multiple domains for certain areas of the application. Since we support different hostnames/subdomains in the routes, being not able to generate this type of route was always a lacking feature for me. |
For what? Example? |
I think iRedds already gave pretty valid examples. If I have something like: |
iRedds example is just an imagination. Why don't you have two apps
In the current implemention, |
We should not require specific architecture from our users. Besides, different domains do not necessarily mean we will deal with different applications. Example. A "social network" app built around sports activities. People are engaging in conversation in the main domain Another example would be different departments in a company, which are under other subdomains. Some parts of the application are common, but others have special modules. Of course, whether these should be separate applications or not is open, but again, that's probably not our role. Anyway, separate applications will not always be justified, and a different domain does not always mean a separate service.
To be clear, something like that? $routes->group('', static function ($routes) {
$routes->('something', 'Whatever::something');
});
$routes->group('', ['hostname' => 'user.example.com'], static function ($routes) {
$routes->('else', 'Whatever::else');
}); Then accessing |
Yes, something like that. In your example the following URLs seem to be accessible: It seems odd to me. Also, if a different department runs a site on a different subdomain, each time a route with no host limitation is added on the main site, the URL for that department's site will also be added automatically. |
Yes, that's true, but the solution for this is very simple. We have to declare the hostname for every route group definition. This way, everything will be separated correctly. |
Okay, thanks. Then the current structure of the $routes array does not look good. |
Description
From https://forum.codeigniter.com/showthread.php?tid=86264
HTTP_HOST do not exist in CLI, so routes for hostnames cannot currently be displayed by
spark routes
.It is strange that
another.domain
is shown as preferred.Before:
After:
Checklist: