|
...
|
...
|
@@ -16,9 +16,16 @@ class EnableCrossRequestMiddleware |
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
|
|
|
$response = $next($request);
|
|
|
|
$response->header('Access-Control-Allow-Origin', '*');
|
|
|
|
$http_origin = "*";
|
|
|
|
if(isset($_SERVER['HTTP_ORIGIN'])){
|
|
|
|
$http_origin = $_SERVER['HTTP_ORIGIN'];
|
|
|
|
}
|
|
|
|
$response->header('Access-Control-Allow-Origin', $http_origin);
|
|
|
|
$response->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
|
|
$response->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Authorization');
|
|
|
|
if (strtolower($_SERVER['REQUEST_METHOD']) == 'options') {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
return $response;
|
|
|
|
// 指定允许其他域名访问
|
|
|
|
// $http_origin = "*";
|
...
|
...
|
|