首页 > 解决方案 > Laravel 5.8 电子邮件验证链接或 APP_URL 部署到服务器后返回 localhost

问题描述

我已经在我的 Laravel 5.8 中配置了 .env 和 config/app.php 中的所有内容,以便在 heroku 中进行生产准备,如下所示:

APP_NAME=Laraclass
APP_ENV=production
APP_KEY=xxx
APP_DEBUG=true
APP_URL=http://larafresh.herokuapp.com

然后我尝试创建一个帐户并检查我的电子邮件验证功能,并且电子邮件中的验证链接或 APP_URL 返回http://localhost:8000,我尝试重新启动我的应用程序,并清除配置但仍然卡住在这里。我不知道这里发生了什么,因为在我创建的另一个链接(电子邮件功能之外)上,它返回到我设置的 APP_URL。

标签: phplaravel

解决方案


如果您首先在服务器中,请不要尝试这个公认的答案。更改 .env 文件中的 APP_URL 取决于严重的问题。

  1. 如果您在本地机器上并且不使用队列。 php artisan config:clear php artisan cache:clear composer dump-autoload php artisan view:clear php artisan route:clear 这足以改变您的本地机器。
  2. 如果您在本地机器上并使用队列。 php artisan config:clear php artisan cache:clear composer dump-autoload php artisan view:clear php artisan route:clear 此外,您必须重新启动队列 php artisan queue:restart php artisan queue:work
  3. 如果您在服务器中并使用队列。 php artisan config:clear php artisan cache:clear composer dump-autoload php artisan view:clear php artisan route:clear 此外,您必须重新启动您的supervisor sudo supervisorctl restart all

推荐阅读