Home > Mobile >  How to redirect 419 page default Laravel in ajax jquery
How to redirect 419 page default Laravel in ajax jquery

Time:10-06

i want to redirect 419 page when user opens new tab and logout, after they click button submit => redirect 419 page I am currently doing the following:

        if (jqXHR.status === 419) {
            return window.location = laroute.route('cms.login');
        }

I want to redirect to screen 419 page expired instead of login screen

Thanks everyone

CodePudding user response:

You can add a route like this and redirect to that route.

Route::get('expired', function () {
    abort('419');
})->name('error.expired');

I don't know if there is a better way of handeling this.

CodePudding user response:

Disable CSRF protection

disable CSRF protection field for routes group or specific routes

open file VerifyCsrfToken.php on your project

dir — App\Http\Middleware\VerifyCsrfToken.php

Try this and let me know if it's working or not. Please check below example. Put your "cms.login" route as below example

<?PHP
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{
  protected $except = [
  'specific-route', // specific route
  ];
}
  • Related