This commit is contained in:
molong
2022-05-24 16:10:50 +08:00
parent a37870c93b
commit d8e43f9e93
63 changed files with 2169 additions and 230 deletions

View File

@@ -12,7 +12,6 @@ namespace app\middleware;
use think\Config;
use think\Request;
use think\Response;
class AllowCrossDomain{
@@ -36,6 +35,7 @@ class AllowCrossDomain{
* @return Response
*/
public function handle($request, \Closure $next, ? array $header = []){
$response = $next($request);
$header = !empty($header) ? array_merge($this->header, $header) : $this->header;
if (!isset($header['Access-Control-Allow-Origin'])) {
@@ -43,6 +43,10 @@ class AllowCrossDomain{
$header['Access-Control-Allow-Origin'] = $origin ? $origin : "*";
}
return $next($request)->header($header);
if (strtoupper($request->method()) == "OPTIONS") {
$response->code(204);
}
return $response->header($header);
}
}