标签:The class lse exp sop get methods options res
$response = $next($request); $IlluminateResponse = ‘Illuminate\Http\Response‘; $SymfonyResopnse = ‘Symfony\Component\HttpFoundation\Response‘; $headers = [ ‘Access-Control-Allow-Origin‘ => ‘*‘, ‘Access-Control-Allow-Methods‘ => ‘POST, GET, OPTIONS, PUT, PATCH, DELETE‘, ‘Access-Control-Allow-Headers‘ => ‘Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Authorization , Access-Control-Request-Headers, X-CSRF-TOKEN‘ ]; if ($response instanceof $IlluminateResponse) { foreach ($headers as $key => $value) { $response->header($key, $value); } return $response; } if ($response instanceof $SymfonyResopnse) { foreach ($headers as $key => $value) { $response->headers->set($key, $value); } // Log::info("request {$request->url()}:", $request->all()); return $response; } return $response;
$response = $next($request); $origin = $request->server(‘HTTP_ORIGIN‘) ? $request->server(‘HTTP_ORIGIN‘) : ‘‘; $response->header(‘Access-Control-Allow-Origin‘, $origin); $response->header(‘Access-Control-Allow-Headers‘, ‘Origin, Content-Type, Cookie, X-CSRF-TOKEN, Accept, Authorization, X-XSRF-TOKEN‘); $response->header(‘Access-Control-Expose-Headers‘, ‘Authorization, authenticated‘); $response->header(‘Access-Control-Allow-Methods‘, ‘GET, POST, PATCH, PUT, OPTIONS‘); $response->header(‘Access-Control-Allow-Credentials‘, ‘true‘); if ($response instanceof \Illuminate\Http\JsonResponse ) { Log::info("response {$request->url()}:", $response->getData(true)); } else{ Log::info("request {$request->url()}:", $request->all()); }
标签:The class lse exp sop get methods options res
原文地址:https://www.cnblogs.com/liyanxi/p/12059578.html