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.
Solved.
appHttpProvidersRouteServiceProvider.php
中 mapRoute
取消強制給加上的web中間件調(diào)用。自己在自己的路由中需要的時候增加 middleware=>web
That’s it
Try not to modify itapp/Http/Kernel.php
,極不推薦關(guān)閉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'
];
}
/app/Http/Kernel.php
第31
行AppHttpMiddlewareVerifyCsrfToken::class,
Delete or comment
It would be better if you take your routing out of the web middleware group.