afa 1 rok pred
rodič
commit
3cbdaeb115

+ 1 - 1
application/admin/controller/Ajax.php

@@ -130,7 +130,7 @@ class Ajax extends Backend
                 $this->error($e->getMessage());
             }
 
-            $this->success(__('Uploaded successful'), '', ['url' => $rs['info']['url'], 'fullurl' => $rs['info']['url']]);
+            $this->success(__('Uploaded successful'), '', ['url' =>str_replace("http://", "https://", $rs['info']['url']), 'fullurl' =>str_replace("http://", "https://", $rs['info']['url'])]);
         }
     }
 

+ 1 - 1
application/common.php

@@ -593,7 +593,7 @@ if (!function_exists('ali_oss_upload')) {
         } catch (UploadException $e) {
             return _error($e->getMessage());
         }
-        return _success(['full_url' => $rs['info']['url']]);
+        return _success(['full_url' => str_replace("http://", "https://",  $rs['info']['url'])]);
     }
 }
 

+ 10 - 0
application/common/controller/Api.php

@@ -15,6 +15,16 @@ use think\Response;
 use think\Route;
 use think\Validate;
 
+//允许跨域
+header('Access-Control-Allow-Origin:*');//允许跨域
+if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS'){
+    // 浏览器页面ajax跨域请求会请求2次,
+    // 第一次会发送OPTIONS预请求,不进行处理,直接exit返回,
+    // 但因为下次发送真正的请求头部有带token,
+    // 所以这里设置允许下次请求头带token否者下次请求无法成功
+    header('Access-Control-Allow-Headers:x-requested-with,content-type,token');
+    exit("ok");
+}
 /**
  * API控制器基类
  */