0
In Laravel 5.2 I want to disable CSRF on a route, because I am using the pagseguro (michaeldouglas/Laravel-pagseguro) and I want to work with the automatic return.
I have tried adding the route in the exception array in the Middlewareverifycsrftoken Http App file
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier{
protected $except = [
'pagseguro/notification',
];
}
I’ve tried deleting and commenting on Verifycsrftoken in the App Http kernel.php
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
//\App\Http\Middleware\VerifyCsrfToken::class,
],
None of the methods worked, I keep getting the error below:
MethodNotAllowedHttpException in RouteCollection.php line 219
Is it not because of the space in
protected $except = [
 ' pagseguro/notification',
 ];
? This error does not seem to be the token, I think the token being would be something liketokenmissmatch exception...
– Miguel
This was a typo, the file was without space. I have changed here too, but nothing to work yet.
– Ricardo Gómez
Do not exclude in kernel. In let only in middleware except
– Miguel
I think the error doesn’t even have to do with the token. I just tested with the route I don’t want in the middleware and ran 5 stars. I think on the routes may be shuffling post/get on this route
– Miguel
It was the first thing I did and did not roll, after I tried to comment the Verifycsrftoken tb did not roll, I tried to delete the Verifycsrftoken tb was not.
– Ricardo Gómez
I created another test route just for that and it was not, I will try to install the zeroed and test.
– Ricardo Gómez
very strange. it worked for me.. And all the articles I read say it’s like this
– Miguel