@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.cjs +6 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3079,6 +3079,9 @@ function resolveLocation(from, location) {
|
|
|
3079
3079
|
return null;
|
|
3080
3080
|
}
|
|
3081
3081
|
}
|
|
3082
|
+
function isBrowserRuntime() {
|
|
3083
|
+
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
3084
|
+
}
|
|
3082
3085
|
async function executeRequest(req, opts = {}) {
|
|
3083
3086
|
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
3084
3087
|
const timeoutMs = opts.timeoutMs === void 0 ? DEFAULT_TIMEOUT_MS : opts.timeoutMs;
|
|
@@ -3103,6 +3106,7 @@ async function executeRequest(req, opts = {}) {
|
|
|
3103
3106
|
() => controller.abort(new Error(`Request timed out after ${timeoutMs}ms`)),
|
|
3104
3107
|
timeoutMs
|
|
3105
3108
|
);
|
|
3109
|
+
const redirectMode = isBrowserRuntime() ? "follow" : "manual";
|
|
3106
3110
|
let currentUrl = builtRequest.url;
|
|
3107
3111
|
let currentHeaders = { ...builtRequest.headers };
|
|
3108
3112
|
let currentMethod = builtRequest.method;
|
|
@@ -3112,7 +3116,7 @@ async function executeRequest(req, opts = {}) {
|
|
|
3112
3116
|
headers: currentHeaders,
|
|
3113
3117
|
body: currentBody,
|
|
3114
3118
|
signal: controller.signal,
|
|
3115
|
-
redirect:
|
|
3119
|
+
redirect: redirectMode
|
|
3116
3120
|
});
|
|
3117
3121
|
let redirectCount = 0;
|
|
3118
3122
|
while (REDIRECT_STATUSES.has(response.status) && redirectCount < MAX_REDIRECTS) {
|
|
@@ -3138,7 +3142,7 @@ async function executeRequest(req, opts = {}) {
|
|
|
3138
3142
|
headers: currentHeaders,
|
|
3139
3143
|
body: currentBody,
|
|
3140
3144
|
signal: controller.signal,
|
|
3141
|
-
redirect:
|
|
3145
|
+
redirect: redirectMode
|
|
3142
3146
|
});
|
|
3143
3147
|
redirectCount++;
|
|
3144
3148
|
}
|