企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
先创建一个中间件 php artisan make:middleware AcceptHeader ~~~ <?php namespace App\Http\Middleware; use Closure; use Illuminate\Http\Request; class AcceptHeader { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ public function handle(Request $request, Closure $next) { $request->headers->set('Accept', 'application/json'); return $next($request); } } ~~~ ~~~ namespace App\Http\Kernel.php ~~~; ~~~ ![](https://img.kancloud.cn/f8/83/f883c8d952662fbbf95a7fd8b6f830c1_933x84.png)