线上环境重置密码的邮件中的链接变成了 localhost
我做到这里, 本地环境测试的结果都是正常的. 但是线上环境重置密码的邮件中的链接变成了 localhost
, 如图:
我上一遍做的是 Laravel 5.5 的版本. 我又打开了上一遍做的线上版本, 测试结果是正常的. 如下图:
因为这一节的内容是发送邮件, 这个功能的逻辑是在框架中写好的, 我并没有做多余的修改.
我看了一些讨论, 邮件中的链接内容应该与 toMail
方法有关, 这是 toMail
方法的内容:
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
if (static::$toMailCallback) {
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
}
return (new MailMessage)
->subject(Lang::getFromJson('Reset Password Notification'))
->line(Lang::getFromJson('You are receiving this email because we received a password reset request for your account.'))
->action(Lang::getFromJson('Reset Password'), url(config('app.url').route('password.reset', $this->token, false)))
->line(Lang::getFromJson('If you did not request a password reset, no further action is required.'));
}
其中 ->action(Lang::getFromJson('Reset Password'), url(config('app.url').route('password.reset', $this->token, false)))
中的 config('app.url')
指的是 config/app.php
文件中的 'url' => env('APP_URL', 'http://localhost'),
.env
文件中: APP_URL=http://weibo.test
我不清楚具体是哪里的问题, 还是我遗漏了什么.
推荐文章: