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
route() helper function does not acknowledge app.url #18613
Comments
The |
Probably related: #14139 |
I think if you don't define the Try clearing the cache first, and then check. |
Yes that's the main purpose of it. |
So if |
Changing the UrlGenerator/RouteUrlGenerator to using app.url would result in all visitors being moved onto one domain; the one specified in app.url. The current behavior is to keep the user on the current domain. Changing this would cause issues for those of us that are running a multi-host setup where we have visitors on many domains. |
this is lacking flexibility however. There should at least be a way to force route() to use a given url for cases where it's needed.. one that doesn't involve doing a str_replace on the default route |
@vesper8 Yes. |
Thanks @sisve ! And it's actually |
I was having problems because I was using Ngrok and the Laravel login.blade.php wanted to post to route('login'), which wasn't honoring my APP_URL. The best hint I found was to not use So then I called Of course, this then meant that I needed to be careful about which of my many local apps was considered the default local Homestead app. So I created an entry higher up in Homestead.yaml with "aaaaaa.test" for the project I was working on. Then /login worked at my Ngrok URL. |
I'm still having trouble; I don't think my weird steps posted above in February are the right approach. I found a related issue (#19556) but no solution yet. |
I think UrlGenerator/RouteUrlGenerator to use the app.url should be the default behavior and overwrite if it needs to be different.
|
Thank you @sisve ! I put the suggestion at my use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\URL;
Route::name('api')
->middleware([
'cors',
'json.response',
'transactional',
])
->group(function () {
// https://github.com/laravel/framework/issues/18613#issuecomment-341991605
$url = config('app.url');
URL::forceRootUrl($url);
// ... |
Yes, this functionality worked for me. For some reason my BrowserSync on this one specific route view was not using port 3000 for all my links, but rather port 8000. Everything else was working just fine. So i shoved this at the top of my |
Description:
I am using the
route($name)
helper function in my views to take advantage of named routes, however if I try to change theapp.url
inconfig/app.php
(APP_URL
environment variable) this doesn't change the prefix of any of the URLs generated byroute($name)
. I discovered this when using an ngrok tunnel's URL to try to demo something I was working on to a colleague.Steps To Reproduce:
app.url
inconfig/app.php
to something other than your hostnameroute($name)
from a viewNotes
I have done some debugging and this is being generated in here:
https://github.com/symfony/http-foundation/blob/master/Request.php#L1244
While this is a Symfony file, it would be amazing if Laravel honoured the
app.url
when generating URLs.This might get shot down as I imagine it's a lot more secure to generate URLs from the hostname rather than some user inputted value but just thought I would float this and see if it's viable.
Thanks!
The text was updated successfully, but these errors were encountered: