mercredi 27 mai 2020

Laravel 5.8 VerifyCsrfToken Exception not working

I'm trying to exclude all requests on an endpoint which I call mydomain.com/code so I do like this in the VerifyCsrfToken.php file.

<?php

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 = [
        'code',
        'code/*'
    ];
}

But it does not solve the issue, even after I try to run "php artisan route:clear && php artisan config:clear", Anyone knows why I can't exclude specific routes? (Laravel 5.8)

My route is something like this:

Route::get('code/testing', 'CodeController@testing');

And the only way I figure out is remove the line "\App\Http\Middleware\VerifyCsrfToken::class," from app/Http/Kernel.php to disable Csrf feature which is not a good solution.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TIsSQ8
via IFTTT

Aucun commentaire:

Enregistrer un commentaire