@aliyun-obv/api 0.0.48 → 0.0.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 +23 -4
  2. package/package.json +3 -3
package/dist/api.es.js CHANGED
@@ -95,6 +95,8 @@ class BaseFetch {
95
95
  let newInit = init;
96
96
  if (hasBaseURL) {
97
97
  url = `${this.defaults.baseURL}${url}`;
98
+ }
99
+ if ((url.startsWith("http:") || url.startsWith("https:")) && !url.startsWith(window.location.host)) {
98
100
  newInit = __spreadValues$4({}, Object.assign({}, init, { credentials: "include" }));
99
101
  }
100
102
  if (this.defaults.beforeRequest) {
@@ -153,7 +155,12 @@ class BaseFetch {
153
155
  const fetchInit = _.merge({}, defaultInit, {
154
156
  body: contentType.includes("application/json") ? JSON.stringify(params) : getPostParam(params)
155
157
  });
156
- const { url: newApi, init: newInit } = yield this.beforeRequest(api, params, fetchInit, options);
158
+ const { url: newApi, init: newInit } = yield this.beforeRequest(
159
+ api,
160
+ params,
161
+ fetchInit,
162
+ options
163
+ );
157
164
  const res = yield this.callFetch(newApi, newInit, options);
158
165
  if (this.defaults.afterResponse) {
159
166
  return yield this.defaults.afterResponse(res, options);
@@ -557,12 +564,13 @@ var __async$4 = (__this, __arguments, generator) => {
557
564
  step((generator = generator.apply(__this, __arguments)).next());
558
565
  });
559
566
  };
567
+ var _a;
560
568
  let slsAccessToken = window.ALIYUN_SLS_CONSOLE_CONFIG.slsAccessToken;
561
569
  let slsAccessTokenMode = false;
562
570
  const urlQueryObj = urijs(location.search).escapeQuerySpace(false).query(true);
563
571
  const supportRefreshToken = urlQueryObj.supportRefreshToken === "true" && window.top !== window.self && parent != null;
564
572
  try {
565
- if (window.ALIYUN_CONSOLE_CONFIG.ENV === "pre") {
573
+ if (((_a = window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _a.ENV) === "pre") {
566
574
  if (urlQueryObj.slsAccessToken) {
567
575
  slsAccessToken = urlQueryObj.slsAccessToken;
568
576
  }
@@ -583,9 +591,9 @@ function waitRefreshToken() {
583
591
  window.addEventListener(
584
592
  "message",
585
593
  (event) => {
586
- var _a, _b, _c;
594
+ var _a2, _b, _c;
587
595
  try {
588
- if (((_a = event == null ? void 0 : event.data) == null ? void 0 : _a.type) === "applyAccessToken" && ((_b = event == null ? void 0 : event.data) == null ? void 0 : _b.ticket) === urlQueryObj.sls_ticket) {
596
+ if (((_a2 = event == null ? void 0 : event.data) == null ? void 0 : _a2.type) === "applyAccessToken" && ((_b = event == null ? void 0 : event.data) == null ? void 0 : _b.ticket) === urlQueryObj.sls_ticket) {
589
597
  slsAccessToken = (_c = event == null ? void 0 : event.data) == null ? void 0 : _c.accessToken;
590
598
  tokenRefreshing = false;
591
599
  const queue = refreshPromisesQueue;
@@ -756,9 +764,20 @@ slsEasyFetch.defaults.afterResponse = (r, options) => __async$3(void 0, null, fu
756
764
  return composedData;
757
765
  });
758
766
 
767
+ function getBaseUrl() {
768
+ var _a, _b;
769
+ if ((_a = window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _a.LOCAL) {
770
+ return `http://pre-observability:${window.location.port}`;
771
+ }
772
+ if (((_b = window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _b.ENV) === "pre") {
773
+ return `https://pre-observability.console.aliyun.com`;
774
+ }
775
+ return `https://observability.console.aliyun.com`;
776
+ }
759
777
  const obsEasyFetch = new BaseFetch(finalFetch);
760
778
  obsEasyFetch.defaults.postDefaultInit.headers["Content-Type"] = "application/x-www-form-urlencoded";
761
779
  obsEasyFetch.defaults.postDefaultInit.headers["Accept"] = "application/json";
780
+ obsEasyFetch.defaults.baseURL = getBaseUrl();
762
781
  obsEasyFetch.defaults.errorHandler = errorHandler;
763
782
  obsEasyFetch.defaults.beforeRequest = slsEasyFetch.defaults.beforeRequest;
764
783
  obsEasyFetch.defaults.afterResponse = slsEasyFetch.defaults.afterResponse;
package/package.json CHANGED
@@ -10,11 +10,11 @@
10
10
  "urijs": "^1.19.1",
11
11
  "lodash": "^4.17.21",
12
12
  "@alicloud/console-base-error-prompt-proxy": "^1.9.12",
13
- "@aliyun-obv/i18n": "0.0.48",
14
- "@aliyun-obv/utils": "0.0.48",
13
+ "@aliyun-obv/i18n": "0.0.50",
14
+ "@aliyun-obv/utils": "0.0.50",
15
15
  "@alifd/next": "^1.27.11",
16
16
  "styled-components": "^5.2.0"
17
17
  },
18
18
  "devDependencies": {},
19
- "version": "0.0.48"
19
+ "version": "0.0.50"
20
20
  }