diff --git a/packages/upload-client/src/blob/add.js b/packages/upload-client/src/blob/add.js index 6872023ac..87d426d71 100644 --- a/packages/upload-client/src/blob/add.js +++ b/packages/upload-client/src/blob/add.js @@ -10,6 +10,7 @@ import retry, { AbortError } from 'p-retry' import { servicePrincipal, connection } from '../service.js' import { REQUEST_RETRIES } from '../constants.js' import { poll } from '../receipts.js' +import { isCloudflareWorkers } from '../runtime.js' /** * @param {string} url @@ -228,7 +229,7 @@ export async function add( try { const res = await fetchWithUploadProgress(address.url, { method: 'PUT', - mode: 'cors', + ...(!isCloudflareWorkers && { mode: 'cors' }), body: bytes, headers: address.headers, signal: options.signal, diff --git a/packages/upload-client/src/runtime.js b/packages/upload-client/src/runtime.js new file mode 100644 index 000000000..b67c0fb2e --- /dev/null +++ b/packages/upload-client/src/runtime.js @@ -0,0 +1,4 @@ +/* c8 ignore next 3 */ +export const isCloudflareWorkers = + typeof navigator !== 'undefined' && + navigator?.userAgent === 'Cloudflare-Workers'