-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
host() in routes with schema and/or port does not work #151
Comments
Thanks for reporting. Do you want to work on pull request w/ tests and the fix? |
I don't write tests, so I don't) I also want to add that my example solution is just an example, and the problem here is probably Here's another example:
Instead, I would like to be able to generate an absolute url as follows:
Or at least something like this:
|
I don't think it's a bug. According to RFC 3986, a host is a part of a URI located between a scheme and a port. Therefore, this |
No. Url generation works correct: Route::get('/home/index')->name('index')->host('http://test.com:8080');
// Result: http://test.com:8080/home/index
$generator->generateAbsolute('index'); Problem with URL matching only.
Good point. We should to decide whether to allow |
router-fastroute/src/UrlMatcher.php
Line 109 in 0916619
What steps will reproduce the problem?
Specify
host()
with a schema and/or port in routesAs example:
What is the expected result?
When I go to the url
http://localhost:8080
in my browser, I will see the page rendered bySiteController::index
What do you get instead?
404 error
Additional info
The problem spot is in the UrlMatcher class, when calling dispatch() on line 107: https://github.com/yiisoft/router-fastroute/blob/master/src/UrlMatcher.php#L107
Only host and path are specified in the
$uri
parameter.But schema and port are returned in
getUri()
separately from host.So, for example, if this
dispatch()
call looked something like this, there wouldn't be a problem:The text was updated successfully, but these errors were encountered: