Commit dfae2965 by 孙龙

跨域

parent 9a848bc2
...@@ -13,12 +13,17 @@ class CrossHttp ...@@ -13,12 +13,17 @@ class CrossHttp
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
$response = $next($request); $response = $next($request);
$response->header('Access-Control-Allow-Origin', "*"); $response = $next($request);
$response->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Cookie,X-Requested-With, X-CSRF-TOKEN, Accept, Authorization, X-XSRF-TOKEN'); $origin = $request->server('HTTP_ORIGIN') ? $request->server('HTTP_ORIGIN') : '';
$response->header('Access-Control-Expose-Headers', 'Authorization, authenticated'); $allow_origin = config("website.cros");
$response->header('Access-Control-Allow-Methods', 'GET, POST, PATCH, PUT, OPTIONS'); if(in_array($origin, $allow_origin)){
$response->header('Access-Control-Allow-Credentials', 'true'); $response->header('Access-Control-Allow-Origin',$origin);
$response->header('Content-type:', 'text/html; charset=utf-8"'); $response->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Cookie,X-Requested-With, 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');
}
return $response; return $response;
} }
} }
\ No newline at end of file
...@@ -22,4 +22,12 @@ return [ ...@@ -22,4 +22,12 @@ return [
// go 服务 // go 服务
'go_server' => 'http://127.0.0.1:8070/', 'go_server' => 'http://127.0.0.1:8070/',
"cros" =>[
"http://order.xiaokang.liexinlocal.com",
"http://order.liexindev.net",
"https://order.liexindev.net",
"http://order.ichunt.net",
"https://order.ichunt.net",
],
]; ];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment