2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-02 16:04:10 +03:00

fix(fetch): fix credentials handling in Cloudflare workers (#6533)

Co-authored-by: Dmitriy Mozgovoy <robotshara@gmail.com>
This commit is contained in:
Hans Otto Wirtz
2024-08-20 14:23:32 +02:00
committed by GitHub
parent bcd1c6d65a
commit 550d885eb9
+4 -1
View File
@@ -155,6 +155,9 @@ export default isFetchSupported && (async (config) => {
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, {
...fetchOptions,
signal: composedSignal,
@@ -162,7 +165,7 @@ export default isFetchSupported && (async (config) => {
headers: headers.normalize().toJSON(),
body: data,
duplex: "half",
credentials: withCredentials
credentials: isCredentialsSupported ? withCredentials : undefined
});
let response = await fetch(request);