ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
~~~ header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: POST, GET, PUT, OPTIONS, DELETE'); //支持的http 动作 header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, x-access-sign, x-access-time'); if (request()->isOptions()) { exit(); } ~~~ 跨域中间件 public function handle($request, \Closure $next) { header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Headers: Authorization, Origin, X-Requested-With, Content-Type,token, Accept, x-access-sign, x-access-time"); header("Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE"); if (strtoupper($request->method()) == "OPTIONS") { return response(); } return $next($request); }