@sanity/client 7.4.0 → 7.5.0-live-cors.0

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
@@ -683,7 +683,7 @@ const encodeQueryString = ({
683
683
  const searchParams = new URLSearchParams(), { tag, includeMutations, returnQuery, ...opts } = options;
684
684
  tag && searchParams.append("tag", tag), searchParams.append("query", query);
685
685
  for (const [key, value] of Object.entries(params))
686
- searchParams.append(`$${key}`, JSON.stringify(value));
686
+ value !== void 0 && searchParams.append(`$${key}`, JSON.stringify(value));
687
687
  for (const [key, value] of Object.entries(opts))
688
688
  value && searchParams.append(key, `${value}`);
689
689
  return returnQuery === !1 && searchParams.append("returnQuery", "false"), includeMutations === !1 && searchParams.append("includeMutations", "false"), `?${searchParams}`;
@@ -1293,7 +1293,11 @@ class LiveClient {
1293
1293
  method: "OPTIONS",
1294
1294
  mode: "cors",
1295
1295
  credentials: esOptions.withCredentials ? "include" : "omit",
1296
- headers: esOptions.headers
1296
+ headers: {
1297
+ ...esOptions.headers,
1298
+ // for this preflight check, ensure we send what the browser would send if needed
1299
+ ...esOptions.headers?.Authorization ? { "Access-Control-Request-Headers": "authorization" } : {}
1300
+ }
1297
1301
  }).pipe(
1298
1302
  rxjs.mergeMap(() => rxjs.EMPTY),
1299
1303
  rxjs.catchError(() => {
@@ -2524,7 +2528,7 @@ function defineDeprecatedCreateClient(createClient2) {
2524
2528
  return config.printNoDefaultExport(), createClient2(config$1);
2525
2529
  };
2526
2530
  }
2527
- var name = "@sanity/client", version = "7.4.0";
2531
+ var name = "@sanity/client", version = "7.5.0-live-cors.0";
2528
2532
  const middleware = [
2529
2533
  middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
2530
2534
  middleware$1.headers({ "User-Agent": `${name} ${version}` }),