File size: 836 Bytes
3679583
 
 
 
 
 
3fd70bc
3679583
 
3fd70bc
 
3679583
 
 
3fd70bc
 
3679583
 
3fd70bc
3679583
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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();