File tree 2 files changed +10
-3
lines changed
2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -14,15 +14,22 @@ const firebaseConfig = {
14
14
15
15
firebase . initializeApp ( firebaseConfig ) ;
16
16
17
+ const auth = firebase . auth ( ) ;
18
+
19
+ if ( window . location . hostname === "localhost" ) {
20
+ console . log ( "Using auth emulator" ) ;
21
+ auth . useEmulator ( "http://localhost:9099" ) ;
22
+ }
23
+
17
24
function useAnonymousLogin ( ) {
18
25
const [ user , setUser ] = useState < firebase . User | null | undefined > ( ) ;
19
26
20
27
useEffect ( ( ) => {
21
- return firebase . auth ( ) . onAuthStateChanged ( ( user ) => {
28
+ return auth . onAuthStateChanged ( ( user ) => {
22
29
setUser ( user ) ;
23
30
24
31
if ( ! user ) {
25
- firebase . auth ( ) . signInAnonymously ( ) . catch ( console . error ) ;
32
+ auth . signInAnonymously ( ) . catch ( console . error ) ;
26
33
return ;
27
34
}
28
35
} ) ;
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ import "firebase/functions";
21
21
const functions = firebase . app ( ) . functions ( "europe-west1" ) ;
22
22
23
23
if ( window . location . hostname === "localhost" ) {
24
- console . log ( "Using emulator" ) ;
24
+ console . log ( "Using functions emulator" ) ;
25
25
functions . useEmulator ( "localhost" , 5001 ) ;
26
26
}
27
27
You can’t perform that action at this time.
0 commit comments