Explorar o código

处理跨域问题

aaa %!s(int64=3) %!d(string=hai) anos
pai
achega
e8745793f1
Modificáronse 1 ficheiros con 3 adicións e 4 borrados
  1. 3 4
      src/utils/axios.js

+ 3 - 4
src/utils/axios.js

@@ -14,10 +14,7 @@ let config = {
   baseURL: process.env.BASE_URL || process.env.VUE_APP_JTXT_URL || "",
   timeout: 60 * 1000,
   withCredentials: false,
-  crossDomain: true,
-  headers: {
-    "Access-Control-Allow-Origin": "*"
-  }
+  crossDomain: true
 };
 
 const _axios = axios.create(config);
@@ -50,6 +47,8 @@ _axios.interceptors.request.use(
       } else if (config.method === "post" && config.data) {
         paramsNew = objKeySort(config.data);
       }
+      config.headers.common["Content-Type"] = "application/json;charset=utf-8";
+      config.headers.common["Access-Control-Allow-Origin"] = "*";
       config.headers.common["userSig"] = "userSig";
       config.headers.common["clientType"] = "h5";
       config.headers.common["timestamp"] = dateChange();