【问题标题】:Laravel 5 - can not reset password on production server 404 - Not FoundLaravel 5 - 无法在生产服务器上重置密码 404 - 未找到
【发布时间】:2017-07-26 09:06:26
【问题描述】:

任何人都知道为什么路由“/password/email”在生产服务器上返回 404 Not Found 错误,但在本地工作?

当用户尝试通过电子邮件 (https://compariimobiliare.ro/password/reset) 重置密码时,POST URL https://compariimobiliare.ro/password/email 会出现 404 Not Found 错误。相同的 URL 在本地服务器上可以正常工作,但在生产环境中不行。

路线就在那里,运行命令就可以看到:

php artisan route:list

POST | password/email | | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail | web,guest 

Laravel 默认实现:

public function sendResetLinkEmail(Request $request)
{
        $this->validate($request, ['email' => 'required|email']);

        // We will send the password reset link to this user. Once we have attempted
        // to send the link, we will examine the response then see the message we
        // need to show to the user. Finally, we'll send out a proper response.
        $response = $this->broker()->sendResetLink(
            $request->only('email')
        );

        if ($response === Password::RESET_LINK_SENT) {
            return back()->with('status', trans($response));
        }

        // If an error was returned by the password broker, we will get this message
        // translated so we can notify a user of the problem. We'll redirect back
        // to where the users came from so they can attempt this process again.
        return back()->withErrors(
            ['email' => trans($response)]
        );
    }

【问题讨论】:

  • 你能在控制器ForgotPasswordController中显示方法sendResetLinkEmail的代码吗?

标签: laravel routes http-status-code-404 password-recovery


【解决方案1】:

我可以看到您有密码/电子邮件的 POST 路由。 你也有密码/电子邮件的 GET 路由吗? 您收到 404 是因为它正在尝试访问 GET 路由。

【讨论】:

  • 这很奇怪,表单使用 POST 操作,但我收到 404 Not found GET 错误...可能是一些奇怪的重定向...尝试使用 Postman 访问“compariimobiliare.ro/password/email”,使用POST 请求,我得到相同的 404 not found 错误。
  • 你是如何处理Controller中的POST请求的?您是否在提交成功表单时重定向用户?你能在 App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail 上分享你的代码
  • 没有自定义,我使用默认的laravel实现,看问题描述和代码。
  • 嗨 Andrei,这似乎是您的 NGINX 服务器的问题,因为如果您尝试使用 /email 的任何 url,它会从 NGINX 服务器提供 404 页面,但如果您尝试说 /test,它会给出您的自定义 404 页面.可能是 /email 已配置为在 NGINX 服务器中使用。只是一个疯狂的猜测
  • 你是对的,我需要看看我有什么奇怪的 nginx 配置,它会导致包含“电子邮件”字样的 URL 上的 404 错误。谢谢!
猜你喜欢
  • 1970-01-01
  • 2022-10-30
  • 2014-05-11
  • 2016-11-08
  • 2017-01-03
  • 2022-08-17
  • 1970-01-01
  • 2015-05-27
  • 2017-12-07
相关资源
最近更新 更多