Browse Source

测试跨域

彭俊 6 years ago
parent
commit
da6015ebee
1 changed files with 3 additions and 3 deletions
  1. 3 3
      app/Http/Middleware/CORS.php

+ 3 - 3
app/Http/Middleware/CORS.php

@@ -15,13 +15,13 @@ class CORS
      */
      */
     public function handle($request, Closure $next)
     public function handle($request, Closure $next)
     {
     {
-        header('Access-Control-Allow-Origin: *');
+//        header('Access-Control-Allow-Origin: *');
 
 
         $headers = [
         $headers = [
+            'Access-Control-Allow-Origin'=> '*',
             'Access-Control-Allow-Methods'=> 'POST, GET, OPTIONS, PUT, DELETE',
             'Access-Control-Allow-Methods'=> 'POST, GET, OPTIONS, PUT, DELETE',
             'Access-Control-Allow-Headers'=> 'Content-Type, X-Auth-Token, Origin',
             'Access-Control-Allow-Headers'=> 'Content-Type, X-Auth-Token, Origin',
-//            'Access-Control-Allow-Origin'=> '*',
-            'Access-Control-Allow-Credentials'=> 'false'
+            'Access-Control-Allow-Credentials'=> 'false',
         ];
         ];
         if($request->getMethod() == "OPTIONS") {
         if($request->getMethod() == "OPTIONS") {
             return Response::make('OK', 200, $headers);
             return Response::make('OK', 200, $headers);