Skip to content

Commit

Permalink
fix: experimental support for cloudflare workers
Browse files Browse the repository at this point in the history
  • Loading branch information
manchenkoff committed Jun 18, 2024
1 parent 932fd0f commit 9146cba
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/runtime/httpFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ function configureClientInterceptors(
}
}

function determineCredentialsMode() {
// Fix for Cloudflare workers - https://github.com/cloudflare/workers-sdk/issues/2514
const isCredentialsSupported = 'credentials' in Request.prototype;

if (!isCredentialsSupported) {
return undefined;
}

return 'include';
}

export function createHttpClient(logger: ConsolaInstance): $Fetch {
const options = useSanctumConfig();
const user = useSanctumUser();
Expand All @@ -53,7 +64,7 @@ export function createHttpClient(logger: ConsolaInstance): $Fetch {

const httpOptions: FetchOptions = {
baseURL: options.baseUrl,
credentials: 'include',
credentials: determineCredentialsMode(),
redirect: 'manual',
retry: options.client.retry,

Expand Down

0 comments on commit 9146cba

Please sign in to comment.