-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[6.x] Use the router for absolute urls #32345
Conversation
Maybe it's best that you explain a bit why this is needed? |
Updated OP to be clearer. |
Let's just do this on 7.x if we're not fixing any real bugs. |
It also fixes when someone has their app.url ending with a slash. It causes urls to be generated with 2 slashes instead of one. |
6.x is definitely the right place for this fix. |
@GrahamCampbell can you rebase? There are some conflicts. |
Is there a way to define the real URL used in tests? I was using |
Looks like I can do |
See laravel/framework#32345 That change caused these tests to ignore app.url and all come from localhost. We could explicitly request using $this->get('http://test.com/something') but I wanted be sure it always happens, in case we end up writing another test and forget to put the absolute url.
This is pretty breaking change. In case having tests for multi domains application it's quite possible that someone used Thanks @jasonvarga - your solution seems to be working fine. |
We're currently treating this as a bug fix. If more people complain this has actually broken this tests, we will look at other options, including reverting. So far only one app has been affected. |
Ah, I was looking for the PR that caused my test suite to fail. Here it is! Just had to change:
to:
|
@GrahamCampbell Let say I have The following test used to pass, now it causes a 404: $this->get('https://secondary.domain.com/something')->assertStatus(200);
$this->get('/main-only')->assertStatus(200); // Previously it was passed now I see 404 error here It probably has no bad effect in production. But I need to change my test. |
It also made my tests failing. I switch the app.url for some tests to |
Thanks for the feedback everyone. I am very hesitant to revert this PR now, since most people to be affected by it have already fixed their code now. If we revert, it will only break everything again for everyone who changed their code! |
This broke the links in my password-reset emails, in my case because while new users were created in an admin subdomain, which triggered a password-reset with broker()->sendResetLink(), the APP_URL and password.reset route were on a different subdomain. Trying to figure out the best way to fix this. |
To answer my own question, this seemed easy enough to add to my User model:
I still don't really understand why this is happening, since if we're asking the router for the absolute URL, and my password.reset route is wrapped in a Route::domain that specifies the correct domain, why doesn't that route return the correct domain instead of the domain for the code that is calling it? |
- Was found that the test was not testing the actual situation anyway. - A work-around in the request creation, within testing, just happened to result in the desired outcome. For reference: laravel/framework#32345
any solve? |
protected function buildMailMessage($url) |
url
already adds in the base path (and everywhere else in the codebase uses this feature already - just search for occurrences ofurl(route(
).