0

All examples of resolving this issue seem to be from older versions of laravel, is there an example using version 8. Also is this something that should be covered in Jetstream?

this below does not work in version 8

if ($exception instanceof \Illuminate\Session\TokenMismatchException) {
    return redirect()->route('login');
}
Jason Spick
  • 6,028
  • 13
  • 40
  • 59
  • Do you have this in app\Exceptions\Handler.php? In public function render($request, Throwable $exception) ? – Thomas Nov 29 '20 at 16:34
  • No, It has register(). no other functions – Jason Spick Nov 29 '20 at 23:39
  • maybe try the Laravel 7 method: https://laravel.com/docs/7.x/errors - "The Report Method". You can paste it into app\Exceptions\Handler.php – Thomas Nov 30 '20 at 09:57
  • Updating this answer for those who are still encountering the problem: Make sure your .env file entries use localhost not an ip-address, or visa versa. AFAIK: Redis is the only service that should use the local IP address. – Curt Doolittle Jul 28 '21 at 19:16

2 Answers2

2

Here is how to do it in Laravel 8 within register method:

    public function register()
    {
        //...

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

composer dump-autoload --no-scripts