Skip to content

Commit

Permalink
Merge pull request #110 from manchenkoff/credentials-provider-experiment
Browse files Browse the repository at this point in the history
fix: experimental support for cloudflare workers
  • Loading branch information
manchenkoff authored Jun 19, 2024
2 parents 68ee54c + 9146cba commit 0ced49c
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 0ced49c

Please sign in to comment.