Laravel 5.2禁用csrf_token

时间:2016-10-04 09:59:14

标签: laravel laravel-5.2

如何为此路线禁用CsrfToken?当我使用网络中间件不起作用时,当我使用这种方式不起作用。请帮忙 这是我的路由器:

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

这是我的verifycsrftoken.php

protected $except = [
    'payment'
];

和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,
];

1 个答案:

答案 0 :(得分:3)

应该是

protected $except = [
    'payment_check/*'
];
验证你的verifycsrftoken.php