FIREBASE_AUTH_EMULATOR_HOST affects all initailized apps, unlike other emulator env var
I maintainer di solito rispondono entro 7 giorni
@lahirumaramba ci sta già lavorando.
Dal 7/7/2025.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
When initializing Firebase Admin to use the emulator, it's required to set the env var FIREBASE_AUTH_EMULATOR_HOST prior to calling initializeApp. This works fine, however, the way this value is used internally has a significant problem: The env var is consulted every time an API call is made. This makes it impossible to have two initialized apps in one process (for example, one pointing to the cloud project, and the other to the emulator.
The relevant code in this repo:
useEmulator is used whenever an API call is made, which affects all applications. So, one application cannot simply set the env var while another unsets it. What's especially confusing about this behavior is that the other env vars don't work like this at all. I can set the var only when needed prior to init, then unset it later to initialize another app.
For example, this works for Firestore and Storage, but not for Auth:
// Initializing an app for remote cloud project access
export const remoteApp = initializeApp(options, "remote")
export const remoteAuth = getAuth(remoteApp)
export const remoteFirestore = getFirestore(remoteApp)
export const remoteStorage = getStorage(remoteApp)
// Initializing a second app for local emulator access
process.env.FIREBASE_AUTH_EMULATOR_HOST="127.0.0.1:9099"
process.env.FIRESTORE_EMULATOR_HOST = "localhost:8080"
process.env.FIREBASE_STORAGE_EMULATOR_HOST = "127.0.0.1:9199"
export const localApp = initializeApp(options, "local")
export const localAuth = getAuth(localApp)
export const localFirestore = getFirestore(localApp)
export const localStorage = getStorage(localApp)
delete process.env.FIREBASE_AUTH_EMULATOR_HOST
delete process.env.FIRESTORE_EMULATOR_HOST
delete process.env.FIREBASE_STORAGE_EMULATOR_HOST
Deleting FIREBASE_AUTH_EMULATOR_HOST here causes the app for the local emulator to instead use the remote service. However, not deleting it causes the remote app to use the local emulator. Again, Firestore and Storage don't have this problem.
As of now, I can't find a way to use emulator auth and remote auth in the same project. It would be great if the admin SDK would take the value of FIREBASE_AUTH_EMULATOR_HOST just once at the time of init, store it, and use it later so that var can be deleted afterward. Or even better, initializeApp could directly take emulator configs as input instead of relying solely on env vars that affect the entire process globally.
See also this comment in another issue: https://github.com/firebase/firebase-admin-node/issues/776#issuecomment-1781154086
- Lingua principale
- TypeScript
- Stelle
- 1.8k
- Fork
- 420
- Merge medio
- 5g 6h
- PR unite (30g)
- 11
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di firebase/firebase-admin-node
-
Password policy violation is reported as `auth/internal-error` instead of a specific error codeAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
firebase/firebase-admin-node#3265 ·
I maintainer di solito rispondono entro 7 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
firebase/firebase-admin-node#3234 ·
I maintainer di solito rispondono entro 7 giorni
-
[email protected] stable dependency tree fails npm audit via Storage uuid and Firestore google-gaxForse già presa @lahirumaramba l’ha presa 23 giorni fa. Aperta
firebase/firebase-admin-node#3221 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 7 giorni
-
api: messaging
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
firebase/firebase-admin-node#3215 ·
I maintainer di solito rispondono entro 7 giorni
-
api: messaging
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
firebase/firebase-admin-node#3214 ·
I maintainer di solito rispondono entro 7 giorni
Tutte le issue di firebase/firebase-admin-node
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
betagouv/mon-entreprise#4699 ·
I maintainer di solito rispondono entro 3 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
jaegertracing/jaeger-ui#4547 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
ai-driven-qa
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
linagora/twake-calendar-frontend#1467 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
need4deed-org/sdk#267 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
auth0/universal-login#414 ·
I maintainer di solito rispondono entro 1 giorno