From b913c647e9045963e4da7ae2e2d161f9b0952deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Salazar?= <73718835+joshrs23@users.noreply.github.com> Date: Mon, 1 Dec 2025 10:02:29 -0500 Subject: [PATCH] another importan configuration for firebase --- frontend-web/src/firebase.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend-web/src/firebase.js b/frontend-web/src/firebase.js index 9f5e6fb4..26d64d59 100644 --- a/frontend-web/src/firebase.js +++ b/frontend-web/src/firebase.js @@ -1,5 +1,5 @@ // Import the functions you need from the SDKs you need -import { initializeApp } from "firebase/app"; +import { initializeApp, getApps, getApp } from "firebase/app"; import { getAuth } from "firebase/auth"; import { getDataConnect } from 'firebase/data-connect'; import { connectorConfig } from '@dataconnect/generated'; @@ -14,7 +14,16 @@ const firebaseConfig = { appId: import.meta.env.VITE_FIREBASE_APP_ID }; -// Initialize Firebase -const app = initializeApp(firebaseConfig); +// Initialize Firebase app only once +let app; +if (getApps().length === 0) { // Check if no app is already initialized + app = initializeApp(firebaseConfig); +} else { + app = getApp(); // If already initialized, use the existing app +} + export const dataConnect = getDataConnect(app, connectorConfig); -export const auth = getAuth(app); \ No newline at end of file +export const auth = getAuth(app); + +// For debugging purposes, if you previously added this, it can stay or be removed +// window.firebaseAuth = auth; \ No newline at end of file