Skip to content

Commit 1ac0e0e

Browse files
committed
Try to get fetch directly
1 parent 804f9ec commit 1ac0e0e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/auth/src/core/util/fetch_provider.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ export class FetchProvider {
4343
if (typeof self !== 'undefined' && 'fetch' in self) {
4444
return self.fetch;
4545
}
46-
if (typeof globalThis !== 'undefined' && 'fetch' in globalThis) {
46+
if (typeof globalThis !== 'undefined' && globalThis.fetch) {
4747
return globalThis.fetch;
4848
}
49+
if (typeof fetch !== 'undefined') {
50+
return fetch;
51+
}
4952
debugFail(
5053
'Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill'
5154
);
@@ -58,9 +61,12 @@ export class FetchProvider {
5861
if (typeof self !== 'undefined' && 'Headers' in self) {
5962
return self.Headers;
6063
}
61-
if (typeof globalThis !== 'undefined' && 'Headers' in globalThis) {
64+
if (typeof globalThis !== 'undefined' && globalThis.Headers) {
6265
return globalThis.Headers;
6366
}
67+
if (typeof Headers !== 'undefined') {
68+
return Headers;
69+
}
6470
debugFail(
6571
'Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill'
6672
);
@@ -73,9 +79,12 @@ export class FetchProvider {
7379
if (typeof self !== 'undefined' && 'Response' in self) {
7480
return self.Response;
7581
}
76-
if (typeof globalThis !== 'undefined' && 'Response' in globalThis) {
82+
if (typeof globalThis !== 'undefined' && globalThis.Response) {
7783
return globalThis.Response;
7884
}
85+
if (typeof Response !== 'undefined') {
86+
return Response;
87+
}
7988
debugFail(
8089
'Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill'
8190
);

0 commit comments

Comments
 (0)