🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ 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); }