I'm using Mail Notifications. When I set QUEUE_DRIVER=sync in my .env file everything is OK:

But if I change the queue driver to database and run php artisan queue:work I receive a wrong URL:

The problem may be related to this issue: https://github.com/laravel/framework/issues/14139
.env
APP_URL=http://mysite.local
QUEUE_DRIVER=database
config/app.php
<?php
return [
'name' => env('APP_NAME', 'Lumen'),
'url' => env('APP_URL', 'http://localhost'),
];
app/Notifications/UserCreated.php
...
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Confirm your email address')
->line('Please, confirm your email address by clicking the button below:')
->action('Confirm email', url('confirm?token=' . $notifiable->verification_token))
->line('Thank you for using our application!');
}
...
The fix, you referenced in the issue, is implemented in Lumen. You can find it in the setRequestForConsole method on line 70 in Laravel\Lumen\Console\Kernel.
However, in the constructor of the same class, a conditional is defined which checks whether the Request has already been bound in the container. If this is the case, the setRequestForConsole will be called.
In the Application class, located in the Lumen framework, the request method will be bound on every request, no matter if you're running in the console or not. That's why the setRequestForConsole method will never get called.
Seems like this was fixed now. Thanks!
Most helpful comment
Seems like this was fixed now. Thanks!