【发布时间】:2021-03-04 16:02:41
【问题描述】:
当我想使用 Laravel 的默认电子邮件验证器时效果很好但是当我将发送电子邮件的相同方法放入队列时,发送给用户的 url 是错误的
http://localhost/email/verify/65/36a5c019a9dc059333f38c329f3694d6ba646e36?expires=1614871373&signature=52f2f377d559a6bdd913b6fc210106b352ed1c60ff64cf1166d2b0ec562f086d
上面的 url 不正确,而不是 localhost:8000 只有 localhost 值
User Model
public function sendEmailVerificationNotification()
{
sendEmailVerify::dispatch($this);
}
Job
public function __construct(User $user)
{
$this->user = $user;
}
public function handle()
{
$this->user->notify(new \App\Notifications\VerifyEmail());
}
【问题讨论】:
-
.env 文件中 app_url 的值是多少?
-
@SachinKumar APP_URL=localhost
-
然后检查我的答案
-
@SachinKumar 这只发生在排队时
-
这将发生在所有独立运行的事情上,比如作业、队列电子邮件。一种快速的解决方案是设置 APP_URL=localhost:8000 但在这种情况下,您必须使用 php artisan serve 命令显式运行服务器,