Mentioned above
Laravel5.5 laravel-cors achieved using cross-domain configuration Laravel
Plug-in to use cross-domain
This method can solve part of the problem api request
But I came across an interface request size exceeds 10k, resulting in cross-domain can not perform to the middleware
Looking at the code, no place to limit the size of the configuration found
The final solution to solve the violence:
In the direct method json api interface, the output header several parameters, as follows:
header("Content-type:text/json"); //跨域 header('Access-Control-Allow-Origin: *'); header('Access-Control-Max-Age: 86400'); header('Access-Control-Allow-Headers: Content-Type, Accept, Authorization, X-Requested-With'); header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, PATCH'); $result = array( 'code' => $code, 'message' => $msg, 'data' => $data ); echo json_encode($result, JSON_UNESCAPED_UNICODE + JSON_UNESCAPED_SLASHES);
Inspired by:
https://learnku.com/laravel/t/3041/middleware-set-response-header-request-header-no-effect
This blog address: wukong1688
This article Original Address: https://www.cnblogs.com/wukong1688/p/11261568.html
Please reprint famous source! Thank you ~ ~