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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user