Ad

Laravel CSRF Protection Exception Now Working

- 1 answer

My Laravel project is in this link

http://localhost/demo/public // laravel project

and I have this external HTML form

http://localhost/attendance

Now I want to send data from the form to Laravel but I got this error

419 Page Expired

so in my laravel project VerifyCsrfToken Class I wrote this

class VerifyCsrfToken extends Middleware
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'http://localhost/attendance'
    ];
}

but still, got the same error

419 Page Expired

Ad

Answer

Laravel resolve for you the baseUrl of your application, there is no need to put the full path, in your case the Middleware should be like below:

class VerifyCsrfToken extends Middleware
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'attendance/*'
    ];
}
Ad
source: stackoverflow.com
Ad