diff --git a/libs/client/src/request.ts b/libs/client/src/request.ts index bf86683..19af2a2 100644 --- a/libs/client/src/request.ts +++ b/libs/client/src/request.ts @@ -1,6 +1,10 @@ import { getConfig } from './config'; import { getUserAgent, isBrowser } from './runtime'; +const isCloudflareWorkers = + typeof navigator !== 'undefined' && + navigator?.userAgent === 'Cloudflare-Workers'; + export async function dispatchRequest( method: string, targetUrl: string, @@ -37,7 +41,7 @@ export async function dispatchRequest( const response = await fetch(url, { method, headers: requestHeaders, - mode: 'cors', + ...(!isCloudflareWorkers && { mode: 'cors' }), body: method.toLowerCase() !== 'get' && input ? JSON.stringify(input)