another importan configuration for firebase
This commit is contained in:
@@ -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);
|
||||
export const auth = getAuth(app);
|
||||
|
||||
// For debugging purposes, if you previously added this, it can stay or be removed
|
||||
// window.firebaseAuth = auth;
|
||||
Reference in New Issue
Block a user