Spaces:
Running
Running
| // src/firebase-config.js | |
| import firebase from 'firebase/compat/app'; // Sử dụng compat nếu bạn vẫn đang dùng API cũ | |
| import 'firebase/compat/auth'; | |
| import 'firebase/compat/firestore'; | |
| // Nếu dùng Firebase v9+ modular SDK, cách import sẽ khác: | |
| // import { initializeApp } from "firebase/app"; | |
| // import { getAuth } from "firebase/auth"; | |
| // import { getFirestore } from "firebase/firestore"; | |
| const firebaseConfig = { | |
| apiKey: "AIzaSyAh3e5wBNfeQX5EO9DALjEQGXH9OrH3bUA", | |
| authDomain: "qlnb-web-app.firebaseapp.com", | |
| databaseURL: "https://qlnb-web-app-default-rtdb.asia-southeast1.firebasedatabase.app", // Có thể không cần nếu chỉ dùng Firestore | |
| projectId: "qlnb-web-app", | |
| storageBucket: "qlnb-web-app.firebasestorage.app", | |
| messagingSenderId: "871217970406", | |
| appId: "1:871217970406:web:6b3482a4efeaa869bccf27", | |
| measurementId: "G-FSGHYLQNSJ" | |
| }; | |
| // Khởi tạo Firebase | |
| if (!firebase.apps.length) { | |
| firebase.initializeApp(firebaseConfig); | |
| } else { | |
| firebase.app(); // if already initialized, use that one | |
| } | |
| const auth = firebase.auth(); | |
| const db = firebase.firestore(); | |
| const FieldValue = firebase.firestore.FieldValue; // Export FieldValue | |
| export { auth, db, FieldValue, firebase }; // Export firebase nếu cần truy cập các dịch vụ khác | |
| // Đối với Firebase v9+ modular SDK: | |
| // const app = initializeApp(firebaseConfig); | |
| // const auth = getAuth(app); | |
| // const db = getFirestore(app); | |
| // export { auth, db }; |