|
|
@@ -6,10 +6,15 @@ class AllowCrossDomain{
|
|
|
|
|
|
public function handle($request, \Closure $next)
|
|
|
{
|
|
|
- header('Access-Control-Allow-Credentials: true');
|
|
|
- header('Access-Control-Allow-Origin: *');
|
|
|
- header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Token");
|
|
|
- header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH');
|
|
|
- return $next($request);
|
|
|
+ header('Access-Control-Allow-Origin: *'); // 或者指定具体域名
|
|
|
+ header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
|
|
|
+ header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
|
|
|
+ header('Access-Control-Allow-Credentials: true');
|
|
|
+
|
|
|
+ if ($request->method() === 'OPTIONS') {
|
|
|
+ return response()->code(204);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $next($request);
|
|
|
}
|
|
|
}
|