I'm trying to setup the storage emulator for my firebase project. I am using the Go admin sdk. However it seems to be ignored despite following the documented process.
App initialization:
func App(ctx context.Context) (*firebase.App, error) {
opt := option.WithCredentialsFile("firebase-service-account.json")
config := firebase.Config{
StorageBucket: "<my-project-id>.appspot.com",
}
app, err := firebase.NewApp(ctx, &config, opt)
if err != nil {
return nil, fmt.Errorf("error initializing app: %v", err)
}
return app, nil
}
.env file loaded on startup:
FIRESTORE_EMULATOR_HOST="localhost:8081"
FIREBASE_STORAGE_EMULATOR_HOST="localhost:9199"
GCLOUD_PROJECT="my-project-id"
I also tried manually setting these by running:
export FIREBASE_STORAGE_EMULATOR_HOST="localhost:9199"
and export GCLOUD_PROJECT="my-project-id"
.
However, when when writing to the default bucket, my blob appears in the actual firestore console for storage, not the storage emulator.
I pulled the GCLOUD_PROJECT
value from my service account json file, the project_id
field specifically. Also confirmed that 9199
is the port that storage is running on.
Besides setting those FIREBASE_STORAGE_EMULATOR_HOST
and GCLOUD_PROJECT
am I missing something else?