Skip to content

Commit a5c8b5b

Browse files
authored
fix(sdk): incorrect fetch initialization on cloudflare (#14009)
Fixes ``` TypeError: Illegal invocation: function called with incorrect this reference. ``` error on Cloudflare - #9463 (comment)
1 parent 209b1f1 commit a5c8b5b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/sdk/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class PayloadSDK<T extends PayloadGeneratedTypes = PayloadGeneratedTypes>
130130
fetch: typeof fetch
131131
constructor(args: Args) {
132132
this.baseURL = args.baseURL
133-
this.fetch = args.fetch ?? globalThis.fetch
133+
this.fetch = args.fetch ?? globalThis.fetch.bind(globalThis)
134134
this.baseInit = args.baseInit ?? {}
135135
}
136136

0 commit comments

Comments
 (0)