-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Description
- Laravel Version: 5.3.22
- PHP Version: 7.0
- Database Driver & Version: N/A
Description:
When using the url helper, the root is calculated by symfony and not picked up according to the APP_URL env variable.
I found out about it when I was trying to use the url helper in an email notification which was sent based on an eloquent event listener (placed in a service provider) while running the app on homestead. The helper didn't pick up the 8000 port. After checking it I noticed the helper is using the request root function which is calculating the root based on a prepareBaseUrl symfony function (look here: https://github.com/laravel/framework/blob/5.3/src/Illuminate/Http/Request.php#L87, while the getBaseUrl is calling prepareBaseUrl), and that function somehow miss the port number in this specific call (from a service provider). So even when I manually set the 8000 port on the APP_URL env variable, nothing changed.
Note - when the email notification was called regularly from a controller, the port was received correctly. It only happened to me when the notification was called from a service provider.
Also, I believe on production there shouldn't be a problem as you don't need a special port like when using homestead.
Steps To Reproduce:
- Create a laravel app locally on homestead.
- Create a mail notification and place a url() helper call in it to some link or asset.
- Create an eloquent event listener in a service provider (for example appServiceProvider (for example a listen to a model creation event) which then sends the email notification.
- Create that model to invoke the listener and the notification sending.
- Look at the returned URL created with the url helper and see there is no 8000 port.