@aliyun-obv/api 0.3.48 → 0.3.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/api.es.js +13 -3
  2. package/package.json +1 -1
package/dist/api.es.js CHANGED
@@ -868,14 +868,24 @@ slsEasyFetch.defaults.postDefaultInit.headers["Accept"] = "application/json";
868
868
  slsEasyFetch.defaults.baseURL = getSLSdomain();
869
869
  slsEasyFetch.defaults.errorHandler = errorHandler;
870
870
  slsEasyFetch.defaults.beforeRequest = (url, params, init, options) => __async$7(void 0, null, function* () {
871
- var _a;
871
+ var _a, _b;
872
872
  const method = (_a = init.method) == null ? void 0 : _a.toLowerCase();
873
873
  if (method === "post" || method === "put") {
874
+ let token = getConfig("SEC_TOKEN");
875
+ if (!token && !isLocal) {
876
+ const response = yield fetch(`${getSLSdomain()}/console/getConfigData.json`, {
877
+ method: "get",
878
+ credentials: "same-origin"
879
+ });
880
+ const res = yield response.json();
881
+ window.ALIYUN_SLS_CONSOLE_CONFIG = __spreadValues$2(__spreadValues$2({}, (_b = window == null ? void 0 : window.ALIYUN_SLS_CONSOLE_CONFIG) != null ? _b : {}), res.data.ALIYUN_SLS_CONSOLE_CONFIG);
882
+ token = getConfig("SEC_TOKEN");
883
+ }
874
884
  let newInit = init;
875
885
  if (options == null ? void 0 : options.restful) {
876
886
  newInit = merge({}, init, {
877
887
  headers: {
878
- "X-CSRF-TOKEN": getConfig("SEC_TOKEN"),
888
+ "X-CSRF-TOKEN": token,
879
889
  "Content-Type": "application/json"
880
890
  },
881
891
  body: JSON.stringify(params)
@@ -883,7 +893,7 @@ slsEasyFetch.defaults.beforeRequest = (url, params, init, options) => __async$7(
883
893
  } else {
884
894
  newInit = merge({}, init, {
885
895
  headers: {
886
- "X-CSRF-TOKEN": getConfig("SEC_TOKEN")
896
+ "X-CSRF-TOKEN": token
887
897
  }
888
898
  });
889
899
  }
package/package.json CHANGED
@@ -15,5 +15,5 @@
15
15
  "styled-components": "^5.2.0",
16
16
  "urijs": "^1.19.1"
17
17
  },
18
- "version": "0.3.48"
18
+ "version": "0.3.50"
19
19
  }