How to remove URL or Route From CSRF Protection

Laravel 7

Nicesnippets

1955

04-04-2020


Hello Friend,

In laravel sometime we need to remove some url or route from X-CSRF-TOKEN Protection. you have to add your url in "VerifyCsrfToken" Middleware. add you url in "$except" array variable.

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;

class VerifyCsrfToken extends Middleware

{

/**

* Indicates whether the XSRF-TOKEN cookie should be set on the response.

*

* @var bool

*/

protected $addHttpCookie = true;

/**

* The URIs that should be excluded from CSRF verification.

*

* @var array

*/

protected $except = [

'https://www.nicesnippets.com/blog',

'https://www.nicesnippets.com/tag/bootstrap-4',

'home/'

];

}

I hope it can help you...