search

Home  >  Q&A  >  body text

Laravel5.2 will add web middleware to routing by default. How to disable it?

Laravel5.2 will add Web middleware to routing by default. How to disable it?

web contains sessioncsrftoken. However, session and csrf are not used at all in the asynchronous notifications of Alipay and WeChat. How to disable.

I don’t want to touch the middleware configuration of verifycsrftoken.

某草草某草草2811 days ago975

reply all(4)I'll reply

  • ringa_lee

    ringa_lee2017-05-16 16:54:38

    Solved.

    appHttpProvidersRouteServiceProvider.phpmapRoute 取消强制给加上的web中间件调用。自己在自己的路由中需要的时候增加 middleware=>web That’s it

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-16 16:54:38

    Try not to modify itapp/Http/Kernel.php,极不推荐关闭CSRF。
    修改app/Http/Middleware/VerifyCsrfToken.php to exclude the specified URL from CSRF verification.

    <?php
    
        namespace App\Http\Middleware;
    
        use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
    
        class VerifyCsrfToken extends BaseVerifier
        {
            /**
             * 指定从 CSRF 验证中排除的URL
             *
             * @var array
             */
            protected $except = [
                'testCsrf'
            ];
        }

    reply
    0
  • 迷茫

    迷茫2017-05-16 16:54:38

    /app/Http/Kernel.php31AppHttpMiddlewareVerifyCsrfToken::class,Delete or comment

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-16 16:54:38

    It would be better if you take your routing out of the web middleware group.

    reply
    0
  • Cancelreply