invertase / dart_firebase_admin

🔥 A Firebase Admin SDK for Dart.
Apache License 2.0
123 stars 40 forks source link

Use environment variables for emulator #52

Open dinko7 opened 1 month ago

dinko7 commented 1 month ago

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.

rrousselGit commented 1 month ago

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