Morteza Negahi
Morteza Negahi

Reputation: 3493

Laravel 5.2 disable csrf_token

How can I disable CsrfToken just for this route ? When I use web Middleware doesn't work, when I use this way doesn't work. help please This is my Router :

 Route::post('payment_check/{order_id}', ['as' => 'payment', 'uses' => 'users\ChargeController@payment_check']);

and here is my verifycsrftoken.php

protected $except = [
    'payment'
];

and Kernel.php

protected $middleware = [
    \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
];

/**
 * The application's route middleware groups.
 *
 * @var array
 */
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,
    ],
    'api' => [
        'throttle:60,1',
    ],
];

/**
 * The application's route middleware.
 *
 * These middleware may be assigned to groups or used individually.
 *
 * @var array
 */
protected $routeMiddleware = [
    'auth' => \App\Http\Middleware\Authenticate::class,
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
    'userAccess' => \App\Http\Middleware\userAccessMiddleWare::class,
    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
    'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];

Upvotes: 1

Views: 187

Answers (1)

Mahfuzul Alam
Mahfuzul Alam

Reputation: 3157

It should be

protected $except = [
    'payment_check/*'
];

in your verifycsrftoken.php

Upvotes: 3

Related Questions