From 8e34bd6a2adc96da9afecaeda627b1ee5f8fdf8a Mon Sep 17 00:00:00 2001 From: spookyuser <16196262+spookyuser@users.noreply.github.com> Date: Tue, 11 Feb 2025 20:59:11 +0200 Subject: [PATCH] Remove window requirement from remot-config --- packages/remote-config/src/client/rest_client.ts | 7 ++++--- packages/remote-config/src/register.ts | 6 +----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/remote-config/src/client/rest_client.ts b/packages/remote-config/src/client/rest_client.ts index 9d87ffbb1ac..4b977a43241 100644 --- a/packages/remote-config/src/client/rest_client.ts +++ b/packages/remote-config/src/client/rest_client.ts @@ -74,9 +74,10 @@ export class RestClient implements RemoteConfigFetchClient { this.firebaseInstallations.getToken() ]); - const urlBase = - window.FIREBASE_REMOTE_CONFIG_URL_BASE || - 'https://firebaseremoteconfig.googleapis.com'; + let urlBase = 'https://firebaseremoteconfig.googleapis.com'; + if (typeof window!== 'undefined' && window.FIREBASE_REMOTE_CONFIG_URL_BASE) { + urlBase = window.FIREBASE_REMOTE_CONFIG_URL_BASE; + } const url = `${urlBase}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=${this.apiKey}`; diff --git a/packages/remote-config/src/register.ts b/packages/remote-config/src/register.ts index ff83e761888..18fc51f6971 100644 --- a/packages/remote-config/src/register.ts +++ b/packages/remote-config/src/register.ts @@ -66,11 +66,7 @@ export function registerRemoteConfig(): void { const installations = container .getProvider('installations-internal') .getImmediate(); - - // Guards against the SDK being used in non-browser environments. - if (typeof window === 'undefined') { - throw ERROR_FACTORY.create(ErrorCode.REGISTRATION_WINDOW); - } + // Guards against the SDK being used when indexedDB is not available. if (!isIndexedDBAvailable()) { throw ERROR_FACTORY.create(ErrorCode.INDEXED_DB_UNAVAILABLE);