-
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
Bug: Redirect to route ignores path set in baseurl #2119
Comments
Addendum: Actually, it would have to use |
That's a good catch. Care to submit a PR? |
To be honest, I'm not sure what the concept behind the URL functions is, i.e., which ones should return paths with |
Resolving relative URI's follows the HTTP specs, so if a '/' is at the beginning of a request it would override any additional segments already there. In this case, I think slash should indicate it is relative to |
base_url does not actually add the base path if the given URL is absolute (i.e., starts with a slash) and does not add the indexPage. Both is necessary for the redirect response to work correctly in case of routes. site_url handles this correctly. Fixes codeigniter4#2119
base_url does not actually add the base path if the given URL is absolute (i.e., starts with a slash) and does not add the indexPage. Both is necessary for the redirect response to work correctly in case of routes. site_url handles this correctly. Fixes codeigniter4#2119
base_url does not actually add the base path if the given URL is absolute (i.e., starts with a slash) and does not add the indexPage. Both is necessary for the redirect response to work correctly in case of routes. site_url handles this correctly. Fixes codeigniter4#2119
base_url does not actually add the base path if the given URL is absolute (i.e., starts with a slash) and does not add the indexPage. Both is necessary for the redirect response to work correctly in case of routes. site_url handles this correctly. Fixes codeigniter4#2119
The PR to fix this is stalled, so removing from rc.3 |
The bug is also in |
@robertotremonti Have you tested this with the latest develop branch, or just rc-3? We've had some URL fixes go into place a week or two ago. |
@lonnieezell I'm using latest 4.0.0-rc.3 release. |
@lonnieezell Anyway I've just tried a quick test by replacing |
Looks like |
All function handling URLs |
In addition, I report that For example |
That's correct, and by design. If you need |
@lonnieezell Your commit solves the problem. Thanks! |
Use site_url for RedirectResponse. Fixes #2119
Describe the bug
When using redirect to route responses in a controller, paths in the configured baseURL are lost.
This is exactly like #1126, but the code has changed since the fix and the cause is now different. I.e., this is a regression.
CodeIgniter 4 version
4.0.0-beta4
Affected module(s)
router
Expected behavior, and steps to reproduce if appropriate
With app.baseURL configured as
http://localhost/path/to/app/
and route configured with$route->get('myController/test', 'MyController::test')
:return redirect()->route('MyController::test')
in a controllerhttp://localhost/path/to/app/myController/test
, buthttp://localhost/myController/test
.Initial analysis pertaining to the cause:
/myController/test
(with preceding slash)RedirectResponse->route
tries to usebase_url
to wrap the pathbase_url
usesURI->resolveRelativeURI
to set the path over thebaseURL
/
and therefore is absolute, completely overriding the pathContext
The text was updated successfully, but these errors were encountered: