fix(sdk): incorrect fetch initialization on cloudflare (#14009)

Fixes
```
TypeError: Illegal invocation: function called with incorrect this reference.
```
error on Cloudflare -
https://github.com/payloadcms/payload/pull/9463#discussion_r2230376819
This commit is contained in:
Sasha
2025-10-01 18:36:46 +03:00
committed by GitHub
parent 209b1f151b
commit a5c8b5bf74

View File

@@ -130,7 +130,7 @@ export class PayloadSDK<T extends PayloadGeneratedTypes = PayloadGeneratedTypes>
fetch: typeof fetch
constructor(args: Args) {
this.baseURL = args.baseURL
this.fetch = args.fetch ?? globalThis.fetch
this.fetch = args.fetch ?? globalThis.fetch.bind(globalThis)
this.baseInit = args.baseInit ?? {}
}