Skip to content

Commit 804f9ec

Browse files
committed
Fix FetchProvider in non-browser environment
1 parent 0ae010e commit 804f9ec

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export class FetchProvider {
4343
if (typeof self !== 'undefined' && 'fetch' in self) {
4444
return self.fetch;
4545
}
46+
if (typeof globalThis !== 'undefined' && 'fetch' in globalThis) {
47+
return globalThis.fetch;
48+
}
4649
debugFail(
4750
'Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill'
4851
);
@@ -55,6 +58,9 @@ export class FetchProvider {
5558
if (typeof self !== 'undefined' && 'Headers' in self) {
5659
return self.Headers;
5760
}
61+
if (typeof globalThis !== 'undefined' && 'Headers' in globalThis) {
62+
return globalThis.Headers;
63+
}
5864
debugFail(
5965
'Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill'
6066
);
@@ -67,6 +73,9 @@ export class FetchProvider {
6773
if (typeof self !== 'undefined' && 'Response' in self) {
6874
return self.Response;
6975
}
76+
if (typeof globalThis !== 'undefined' && 'Response' in globalThis) {
77+
return globalThis.Response;
78+
}
7079
debugFail(
7180
'Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill'
7281
);

0 commit comments

Comments
 (0)