@ctil/gql 1.0.5 → 1.0.7

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.
package/dist/index.cjs CHANGED
@@ -4297,8 +4297,8 @@ var import_fs = __toESM(require("fs"), 1);
4297
4297
  var import_path = __toESM(require("path"), 1);
4298
4298
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
4299
4299
  var isNode2 = typeof process !== "undefined" && process.versions?.node != null;
4300
- var NODE_LOGIN_FILE = import_path.default.resolve(process.cwd(), "loginInfo.json");
4301
- var NODE_LOGIN_REMEBER_FILE = import_path.default.resolve(process.cwd(), "loginInfo.json.remember");
4300
+ var NODE_LOGIN_FILE = isNode2 ? import_path.default.resolve(process.cwd(), "loginInfo.json") : "";
4301
+ var NODE_LOGIN_REMEBER_FILE = isNode2 ? import_path.default.resolve(process.cwd(), "loginInfo.json.remember") : "";
4302
4302
  var STORAGE_KEY = "GRAPHQL_LOGIN_INFO";
4303
4303
  var REMEMBER_KEY = "GRAPHQL_LOGIN_REMEMBER";
4304
4304
  var nodeLoginInfo = null;
@@ -4319,9 +4319,19 @@ var CCRequest = class {
4319
4319
  }
4320
4320
  /** 构建 GraphQLClient 实例 */
4321
4321
  buildClient() {
4322
- this.client = new import_graphql_request.GraphQLClient(this.config.endpoint || "/graphql", {
4323
- headers: this.headers
4324
- });
4322
+ const options = { headers: this.headers };
4323
+ if (isBrowser) {
4324
+ const corsMode = this.config.corsMode || "cors";
4325
+ const withCred = !!this.config.withCredentials;
4326
+ options.fetch = (input, init) => {
4327
+ return fetch(input, {
4328
+ ...init,
4329
+ mode: corsMode,
4330
+ credentials: withCred ? "include" : init?.credentials
4331
+ });
4332
+ };
4333
+ }
4334
+ this.client = new import_graphql_request.GraphQLClient(this.config.endpoint || "/graphql", options);
4325
4335
  }
4326
4336
  /** 构建初始 headers */
4327
4337
  buildHeaders(config) {