| import { initializeApp } from 'firebase/app'; | |
| import { getAuth } from 'firebase/auth'; | |
| import { getFirestore, doc, getDocFromServer } from 'firebase/firestore'; | |
| import firebaseConfig from '../../firebase-applet-config.json'; | |
| const app = initializeApp(firebaseConfig); | |
| export const db = getFirestore(app, firebaseConfig.firestoreDatabaseId || undefined); | |
| export const auth = getAuth(app); | |
| console.log("Firebase initialized with project:", firebaseConfig.projectId, "Database:", firebaseConfig.firestoreDatabaseId || "(default)"); | |
| async function testConnection() { | |
| try { | |
| if (typeof window !== 'undefined') { | |
| // Silently attempt a connection test | |
| await getDocFromServer(doc(db, '_connection_test_', 'ping')).catch(() => {}); | |
| } | |
| } catch (error) { | |
| // Ignore errors in background test | |
| } | |
| } | |
| testConnection(); | |