mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
fix(fetch): fix credentials handling in Cloudflare workers (#6533)
Co-authored-by: Dmitriy Mozgovoy <robotshara@gmail.com>
This commit is contained in:
@@ -155,6 +155,9 @@ export default isFetchSupported && (async (config) => {
|
|||||||
withCredentials = withCredentials ? 'include' : 'omit';
|
withCredentials = withCredentials ? 'include' : 'omit';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cloudflare Workers throws when credentials are defined
|
||||||
|
// see https://github.com/cloudflare/workerd/issues/902
|
||||||
|
const isCredentialsSupported = "credentials" in Request.prototype;
|
||||||
request = new Request(url, {
|
request = new Request(url, {
|
||||||
...fetchOptions,
|
...fetchOptions,
|
||||||
signal: composedSignal,
|
signal: composedSignal,
|
||||||
@@ -162,7 +165,7 @@ export default isFetchSupported && (async (config) => {
|
|||||||
headers: headers.normalize().toJSON(),
|
headers: headers.normalize().toJSON(),
|
||||||
body: data,
|
body: data,
|
||||||
duplex: "half",
|
duplex: "half",
|
||||||
credentials: withCredentials
|
credentials: isCredentialsSupported ? withCredentials : undefined
|
||||||
});
|
});
|
||||||
|
|
||||||
let response = await fetch(request);
|
let response = await fetch(request);
|
||||||
|
|||||||
Reference in New Issue
Block a user