@ctil/gql 1.0.6 → 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
@@ -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) {