firebase-admin-node
firebase-admin-node copied to clipboard
[FR] Abillity to connect auth and storage emulator without env variables
Is your feature request related to a problem? Please describe. I want to make a copy of my production env to develop locally, for this purpose, i need to copy data from firestore and some blob from storage. To connect the firestore sdk locally, you can do
admin.firestore().settings(...)
For other products like auth or storage, this kind of settings is not possible and you must provide an environment variable.
But all app
initialized share this env variables and won't allow you to connect to both production and emulator environment
Describe the solution you'd like
Provide an interface like the settings
of firestore for other emulator products
Describe alternatives you've considered
- Override
baseUrl
andapiEndpoint
for my current storage instance - Use scripts to export/import my production data
I found a few problems with this issue:
- I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
- This issue does not seem to follow the issue template. Make sure you provide all the required information.
The same process connecting to both prod and emulator services is not something we particularly want to encourage. @yuchenshi wdyt?
There are multiple points in this issue that I'll address separately.
Importing production data into emulators: We recommend first taking snapshot exports (Firestore | Auth | Storage) and then using emulator imports or scripts to load the snapshots to the emulators. For Firestore, this is now possible without even needing Admin SDKs or custom scripts. We're still working on the ergonomics for Auth and Storage so you may need some scripting for now, but the essentials are the same. The script should read from the snapshot files and will never need to connect to production.
Mixed use of production and emulators: As @hiranya911 said, connecting to prod and emulator in the same process is strongly discouraged. It's just too easy to change production unintentionally especially with all the credentials. (Yes, there are workarounds such as changing environment variables and creating new apps once the script is done with production. No, we'd rather people don't do it at all, or at least use separate processes.)
Programatic APIs to connect to emulators: While we're not prioritizing this because most use cases are unblocked by environment variables, we understand programatic APIs are desirable in other valid use cases and we're open to PRs. The API should follow the corresponding Web JS SDK v8 precedences, such as admin.storage().useEmulator('localhost', 8080)
. (It is worth reiterating that such APIs, even if implemented, should not be used in a way that mixes production and emulators.)