File tree Expand file tree Collapse file tree 2 files changed +5
-15
lines changed
Expand file tree Collapse file tree 2 files changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -24,29 +24,18 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
2424 const [ loading , setLoading ] = useState ( true ) ;
2525
2626 useEffect ( ( ) => {
27- console . log ( '🔐 AuthProvider - Démarrage ULTRA-RAPIDE' ) ;
28-
29- // Timeout de 500ms maximum pour éviter les blocages
30- const quickTimeout = setTimeout ( ( ) => {
31- console . log ( '🔐 TIMEOUT 500ms - affichage immédiat' ) ;
32- setLoading ( false ) ;
33- } , 500 ) ;
27+ console . log ( '🔐 AuthProvider - Initialisation stable' ) ;
3428
3529 const unsubscribe = onAuthStateChanged ( auth , ( user ) => {
3630 console . log ( '🔐 Auth state reçu:' , user ? 'CONNECTÉ' : 'DÉCONNECTÉ' ) ;
37- clearTimeout ( quickTimeout ) ;
3831 setUser ( user ) ;
3932 setLoading ( false ) ;
4033 } , ( error ) => {
4134 console . error ( '🚨 Erreur Auth:' , error ) ;
42- clearTimeout ( quickTimeout ) ;
4335 setLoading ( false ) ;
4436 } ) ;
4537
46- return ( ) => {
47- clearTimeout ( quickTimeout ) ;
48- unsubscribe ( ) ;
49- } ;
38+ return unsubscribe ;
5039 } , [ ] ) ;
5140
5241 const signInWithEmail = async ( email : string , password : string ) => {
Original file line number Diff line number Diff line change 11
2- import { initializeApp } from "firebase/app" ;
2+ import { initializeApp , getApps , getApp } from "firebase/app" ;
33import { getAuth , GoogleAuthProvider } from "firebase/auth" ;
44import { getFirestore } from "firebase/firestore" ;
55
@@ -32,7 +32,8 @@ const firebaseConfig = {
3232
3333console . log ( '🔥 Firebase config chargée depuis les variables d\'environnement' ) ;
3434
35- const app = initializeApp ( firebaseConfig ) ;
35+ // Éviter la double initialisation de Firebase
36+ const app = getApps ( ) . length === 0 ? initializeApp ( firebaseConfig ) : getApp ( ) ;
3637
3738export const auth = getAuth ( app ) ;
3839export const db = getFirestore ( app ) ;
You can’t perform that action at this time.
0 commit comments