通过排队验证电子邮件,将错误的 URL 发送到用户的电子邮件



当我想使用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 AppNotificationsVerifyEmail());
}

如果您正在使用artisan queue:work,您还必须在更改.env文件中的应用程序URL后重新启动工作程序。

将APP_URL的值更改为
APP_URL=http://localhost:8000

然后运行php-artisan-config:clear或php-artisan-config:cache

或者,如果您正在使用php-artisan-service,只需重新启动它,它就会工作。

存在这种问题是因为队列作业选择了env配置值,在您的情况下,APP_URL设置为http://localhost/我想。

因此,将APP_URL更改为.env文件(如)中本地服务器的路径

APP_URL=http://localhost/laravel

其中laravel是我运行项目的文件夹名。

最新更新