laravel11中如何关闭csrf验证
xuexi 2025-01-07 09:08:11 发表在:PHP 查看数:370

laravel11中如何关闭csrf验证 找到 bootstrap/app.php 文件 设置 $middleware->validateCsrfTokens(['*']) 完整代码如下

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        api: __DIR__.'/../routes/api.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->validateCsrfTokens([
            '*'
        ]);
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })->create();
最近访问时间:2025-03-25 08:51:50
知识库:331条鸣谢:TAY  备案号:蜀ICP备2024090044号