Attempted import error: 'dbAdmin' is not exported from '@/lib/firebase/admin' (imported as 'dbAdmin'
Unanswered
English Angora posted this in #help-forum
English AngoraOP
import "server-only";
import { initializeApp, getApps, getApp, cert, App } from "firebase-admin/app";
import { getAuth, Auth } from "firebase-admin/auth";
import { getFirestore, Firestore } from "firebase-admin/firestore";
const serviceAccount = {
projectId: process.env.FIREBASE_PROJECT_ID,
clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
privateKey: process.env.FIREBASE_PRIVATE_KEY?.replace(/\\n/g, "\n"),
};
let appAdmin: App;
if (getApps().length === 0) {
if (serviceAccount.projectId && serviceAccount.clientEmail && serviceAccount.privateKey) {
appAdmin = initializeApp({
credential: cert(serviceAccount),
});
} else {
console.warn(
"Les infos Firebase Admin sont incomplètes. Initialisation avec les identifiants par défaut."
);
appAdmin = initializeApp();
}
} else {
appAdmin = getApp();
}
const authAdmin: Auth = getAuth(appAdmin);
const dbAdmin: Firestore = getFirestore(appAdmin);
export { appAdmin, authAdmin, dbAdmin };
2 Replies
Chub mackerel
check your import path again
English AngoraOP
yeah, no work