企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ //修改 app/Http/Middleware/VerifyCsrfToken.php 文件 <?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier; use Closure; class VerifyCsrfToken extends BaseVerifier { /** * The URIs that should be excluded from CSRF verification. * * @var array */ protected $except = [ // ]; public function handle($request, Closure $next) { // 如果是来自 api 域名,就跳过检查 if ($_SERVER['SERVER_NAME'] != config('api.domain')) { return parent::handle($request, $next); } return $next($request); } } ~~~ 去除CSRF TOKEN的保护 ~~~ Route::post('wechatmp', 'WechatController@responseMsg'); class VerifyCsrfToken extends BaseVerifier { protected $except = [ 'wechatmp', ]; } ~~~ 禁用特定路由的csrf http://www.camroncade.com/disable-csrf-for-specific-routes-laravel-5/