Disabling the CSRF Middleware in Laravel 5

Reading time: less than 1 minute

Disabling the CSRF Middleware in Laravel 5

How to stop CSRF verification from all routes?

Go to app/Http/Middleware/ and edit file VerifyCsrfToken.php


<?php

namespace App\Http\Middleware;

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

class VerifyCsrfToken extends BaseVerifier
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        //
    ];

    public function handle($request, Closure $next)
    {
      return $next($request);
    }
}