Official Document Said That
- create app instance
- create auth instance
- then connect with emulator
const app = initializeApp(config.firebase)
const auth = getAuth(app)
connectAuthEmulator(auth, 'http://localhost:9099', { disableWarnings: true })
// note: 9099 is the default port Firebase used for their authen emulator
But I got this when logged-in
Uncaught FirebaseError: Firebase: Error (auth/emulator-config-failed).
Here's the Solution
From developer best friend Stackoverflow
async function setupEmulators(auth) {
const authUrl = 'http://localhost:9099'
await fetch(authUrl)
connectAuthEmulator(auth, 'http://localhost:9099', { disableWarnings: true })
// why? to make sure that emulator are loaded
}
const app = initializeApp(config.firebase)
const auth = getAuth(app)
setupEmulators(auth)
Happy
Top comments (1)
Thanks a lot!