withHeader('Access-Control-Allow-Origin', '*') ->withHeader('Access-Control-Allow-Credentials', 'true') // Headers 可以根据实际情况进行改写。 ->withHeader('Access-Control-Allow-Headers', 'DNT,Keep-Alive,User-Agent,Cache-Control,Content-Type,Authorization'); Context::set(ResponseInterface::class, $response); if ($request->getMethod() == 'OPTIONS') { return $response; } // $request = \Hyperf\Utils\Context::override(ServerRequestInterface::class, function (ServerRequestInterface $request) // { // $preDatas = $request->getParsedBody(); // if(isset($preDatas['market_id'])){ // if($preDatas['market_id']==-1){ // $preDatas['market_id'] = 0; // // if (env('APP_ENV') == 'prod') { // unset($preDatas['sign']); // $sign = $this->signature($preDatas); // $preDatas['sign'] = $sign; // } // } // } // return $request->withParsedBody($preDatas); // }); return $handler->handle($request); } // private function signature($params) // { // ksort($params); // // $http_query = []; // foreach ($params as $key => $value) { // $http_query[] = $key.'='.$value; // } // // return sha1(md5(implode('&', $http_query)).config('auth.api.sign.secret_key')); // } }