@apicircle/core 1.0.5 → 1.0.6

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.js CHANGED
@@ -2943,6 +2943,9 @@ function resolveLocation(from, location) {
2943
2943
  return null;
2944
2944
  }
2945
2945
  }
2946
+ function isBrowserRuntime() {
2947
+ return typeof window !== "undefined" && typeof window.document !== "undefined";
2948
+ }
2946
2949
  async function executeRequest(req, opts = {}) {
2947
2950
  const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
2948
2951
  const timeoutMs = opts.timeoutMs === void 0 ? DEFAULT_TIMEOUT_MS : opts.timeoutMs;
@@ -2967,6 +2970,7 @@ async function executeRequest(req, opts = {}) {
2967
2970
  () => controller.abort(new Error(`Request timed out after ${timeoutMs}ms`)),
2968
2971
  timeoutMs
2969
2972
  );
2973
+ const redirectMode = isBrowserRuntime() ? "follow" : "manual";
2970
2974
  let currentUrl = builtRequest.url;
2971
2975
  let currentHeaders = { ...builtRequest.headers };
2972
2976
  let currentMethod = builtRequest.method;
@@ -2976,7 +2980,7 @@ async function executeRequest(req, opts = {}) {
2976
2980
  headers: currentHeaders,
2977
2981
  body: currentBody,
2978
2982
  signal: controller.signal,
2979
- redirect: "manual"
2983
+ redirect: redirectMode
2980
2984
  });
2981
2985
  let redirectCount = 0;
2982
2986
  while (REDIRECT_STATUSES.has(response.status) && redirectCount < MAX_REDIRECTS) {
@@ -3002,7 +3006,7 @@ async function executeRequest(req, opts = {}) {
3002
3006
  headers: currentHeaders,
3003
3007
  body: currentBody,
3004
3008
  signal: controller.signal,
3005
- redirect: "manual"
3009
+ redirect: redirectMode
3006
3010
  });
3007
3011
  redirectCount++;
3008
3012
  }