dart_firebase_admin icon indicating copy to clipboard operation
dart_firebase_admin copied to clipboard

Use environment variables for emulator

Open dinko7 opened this issue 1 year ago • 1 comments

First of all, thank you making this SDK.

When using an emulator, I can specify port for different emulators using firebase.json.

Example firebase.json:

{
  "emulators": {
    "auth": {
      "port": 9000
    },
    "firestore": {
      "port": 8000
    },
  }
}

In that case, the SDK doesn't connect to the emulator because hardcoded values are used.

firebase_admin_app.dart:

void useEmulator() {
    _isUsingEmulator = true;
    authApiHost = Uri.http('127.0.0.1:9099', 'identitytoolkit.googleapis.com/');
    firestoreApiHost = Uri.http('127.0.0.1:8080', '/');
  }

Firebase documentation specifies the following environment variables that are being set by the emulator that can be used instead of hardcoded values:

FIREBASE_AUTH_EMULATOR_HOST Docs FIRESTORE_EMULATOR_HOST Docs

I'm happy to contribute if you are busy.

dinko7 avatar Sep 29 '24 11:09 dinko7

Sure, I'd be happy to see a PR :)

rrousselGit avatar Sep 29 '24 17:09 rrousselGit