【问题标题】:419 | Page Expired on logout Laravel 8 Jetstream419 |退出时页面已过期 Laravel 8 Jetstream
【发布时间】:2021-02-17 01:06:18
【问题描述】:

解决此问题的所有示例似乎都来自旧版本的 laravel,是否有使用版本 8 的示例。这也是 Jetstream 应该涵盖的内容吗?

以下内容在版本 8 中不起作用

if ($exception instanceof \Illuminate\Session\TokenMismatchException) {
    return redirect()->route('login');
}

【问题讨论】:

  • 你在 app\Exceptions\Handler.php 中有这个吗?在公共函数中 render($request, Throwable $exception) ?
  • 不,它有 register()。没有其他功能
  • 也许可以试试 Laravel 7 方法:laravel.com/docs/7.x/errors - “报告方法”。您可以将其粘贴到 app\Exceptions\Handler.php
  • 为仍然遇到问题的人更新此答案:确保您的 .env 文件条目使用 localhost 而不是 IP 地址,反之亦然。 AFAIK:Redis 是唯一应该使用本地 IP 地址的服务。

标签: laravel laravel-8 jetstream


【解决方案1】:

以下是在 Laravel 8 中注册方法的方法:

    public function register()
    {
        //...

        $this->renderable(function (Throwable $e) {
            if ($e->getPrevious() instanceof \Illuminate\Session\TokenMismatchException) {
                return redirect()->route('login');
            }
        });
    }

【讨论】:

    猜你喜欢
    • 2020-05-22
    • 2022-06-11
    • 1970-01-01
    • 2021-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-06
    • 2020-06-02
    相关资源
    最近更新 更多