firebase / firebase-tools

The Firebase Command Line Tools
MIT License
3.99k stars 921 forks source link

Storage emulator does not accept multiple storage targets configuration #3390

Closed DennisAlund closed 2 years ago

DennisAlund commented 3 years ago

[REQUIRED] Environment info

firebase-tools: 9.11.0

Platform: macOS 11.3.1

[REQUIRED] Test case

Follow the steps to set up multiple storage targets: https://firebase.google.com/docs/cli/targets#set-up-deploy-target-storage-database

Ensure that the firebase.json configuration has an array of storage targets

{
 // ... your other firebase configuration
 "storage": [
    {
      "rules": "storage.rules",
      "target": "default"
    },
    {
      "rules": "our-other-target.rules",
      "target": "our-other-target"
    }
  ]
  // ... rest of configuration
}

[REQUIRED] Steps to reproduce

  1. Configure multiple storage targets as described https://firebase.google.com/docs/cli/targets#set-up-deploy-target-storage-database
  2. Start emulators
  3. See error: Cannot start the Storage emulator without rules file specified in firebase.json: run 'firebase init' and set up your Storage configuration
  4. Remove the array of targets and declare single target as object, not array declaration
  5. Start emulators
  6. Success

[REQUIRED] Expected behavior

Configuration that is acceptable for regular deployment should be acceptable for emulator.

[REQUIRED] Actual behavior

Get error when starting the emulators with multiple storage targets

Output

$ firebase emulators:start
i  emulators: Starting emulators: auth, functions, firestore, database, hosting, pubsub, storage
✔  functions: Using node@14 from host.
i  firestore: Firestore Emulator logging to firestore-debug.log
i  database: Database Emulator logging to database-debug.log
i  pubsub: Pub/Sub Emulator logging to pubsub-debug.log
i  emulators: Shutting down emulators.
i  functions: Stopping Functions Emulator
i  database: Stopping Database Emulator
i  firestore: Stopping Firestore Emulator
i  pubsub: Stopping Pub/Sub Emulator
i  auth: Stopping Authentication Emulator
i  hub: Stopping emulator hub

Error: Cannot start the Storage emulator without rules file specified in firebase.json: run 'firebase init' and set up your Storage configuration

Output with debug flags

[2021-05-20T06:58:23.662Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2021-05-20T06:58:23.663Z] > authorizing via signed-in user (dennis@oddbit.id)
i  emulators: Starting emulators: auth, functions, firestore, database, hosting, pubsub, storage {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: auth, functions, firestore, database, hosting, pubsub, storage"}}
[2021-05-20T06:58:23.680Z] [hub] writing locator at /var/folders/d9/6zn6x8jx2_d9z478l51g275w0000gn/T/hub-cruscott---dev.json
✔  functions: Using node@14 from host. {"metadata":{"emulator":{"name":"functions"},"message":"Using node@14 from host."}}
[2021-05-20T06:58:23.717Z] defaultcredentials: writing to file /Users/dennis/.config/firebase/dennis_oddbit_id_application_default_credentials.json
[2021-05-20T06:58:23.720Z] Setting GAC to /Users/dennis/.config/firebase/dennis_oddbit_id_application_default_credentials.json {"metadata":{"emulator":{"name":"functions"},"message":"Setting GAC to /Users/dennis/.config/firebase/dennis_oddbit_id_application_default_credentials.json"}}
[2021-05-20T06:58:23.722Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/cruscott---dev/adminSdkConfig [none]
[2021-05-20T06:58:24.238Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/cruscott---dev/adminSdkConfig 200
[2021-05-20T06:58:24.239Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/cruscott---dev/adminSdkConfig {"projectId":"cruscott---dev","databaseURL":"https://cruscott---dev.firebaseio.com","storageBucket":"cruscott---dev.appspot.com","locationId":"europe-west"}
[2021-05-20T06:58:24.271Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: projectId"}}
[2021-05-20T06:58:24.272Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[2021-05-20T06:58:24.272Z] Starting Firestore Emulator with command {"binary":"java","args":["-Dgoogle.cloud_firestore.debug_log_level=FINE","-Duser.language=en","-jar","/Users/dennis/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.15.jar","--host","localhost","--port",8080,"--rules","/Users/dennis/development/Almo-Nature/agora/firestore.rules","--functions_emulator","localhost:5001"],"optionalArgs":["port","webchannel_port","host","rules","functions_emulator","seed_from_export"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {\"binary\":\"java\",\"args\":[\"-Dgoogle.cloud_firestore.debug_log_level=FINE\",\"-Duser.language=en\",\"-jar\",\"/Users/dennis/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.15.jar\",\"--host\",\"localhost\",\"--port\",8080,\"--rules\",\"/Users/dennis/development/Almo-Nature/agora/firestore.rules\",\"--functions_emulator\",\"localhost:5001\"],\"optionalArgs\":[\"port\",\"webchannel_port\",\"host\",\"rules\",\"functions_emulator\",\"seed_from_export\"],\"joinArgs\":false}"}}
i  firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
[2021-05-20T06:58:25.169Z] May 20, 2021 2:58:25 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start
INFO: Started WebSocket server on ws://localhost:64196
 {"metadata":{"emulator":{"name":"firestore"},"message":"May 20, 2021 2:58:25 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start\nINFO: Started WebSocket server on ws://localhost:64196\n"}}
[2021-05-20T06:58:25.225Z] API endpoint: http://localhost: {"metadata":{"emulator":{"name":"firestore"},"message":"API endpoint: http://localhost:"}}
[2021-05-20T06:58:25.226Z] 8080
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

   export FIRESTORE_EMULATOR_HOST=localhost: {"metadata":{"emulator":{"name":"firestore"},"message":"8080\nIf you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:\n\n   export FIRESTORE_EMULATOR_HOST=localhost:"}}
[2021-05-20T06:58:25.226Z] 8080

Dev App Server is now running.

 {"metadata":{"emulator":{"name":"firestore"},"message":"8080\n\nDev App Server is now running.\n\n"}}
[2021-05-20T06:58:25.302Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/cruscott---dev [none]
[2021-05-20T06:58:25.718Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/cruscott---dev 200
[2021-05-20T06:58:25.718Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/cruscott---dev {"projectId":"cruscott---dev","projectNumber":"996240691979","displayName":"Cruscott - DEV","name":"projects/cruscott---dev","resources":{"hostingSite":"cruscott---dev","realtimeDatabaseInstance":"cruscott---dev","storageBucket":"cruscott---dev.appspot.com","locationId":"europe-west"},"state":"ACTIVE"}
[2021-05-20T06:58:25.718Z] database rules config:  [{"instance":"cruscott---dev","rules":"/Users/dennis/development/Almo-Nature/agora/database.rules.json"}]
[2021-05-20T06:58:25.720Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: projectId"}}
[2021-05-20T06:58:25.720Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: auto_download"}}
[2021-05-20T06:58:25.720Z] Ignoring unsupported arg: rules {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: rules"}}
[2021-05-20T06:58:25.720Z] Starting Database Emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/Users/dennis/.cache/firebase/emulators/firebase-database-emulator-v4.7.2.jar","--host","localhost","--port",9000,"--functions_emulator_host","localhost","--functions_emulator_port",5001],"optionalArgs":["port","host","functions_emulator_port","functions_emulator_host"],"joinArgs":false} {"metadata":{"emulator":{"name":"database"},"message":"Starting Database Emulator with command {\"binary\":\"java\",\"args\":[\"-Duser.language=en\",\"-jar\",\"/Users/dennis/.cache/firebase/emulators/firebase-database-emulator-v4.7.2.jar\",\"--host\",\"localhost\",\"--port\",9000,\"--functions_emulator_host\",\"localhost\",\"--functions_emulator_port\",5001],\"optionalArgs\":[\"port\",\"host\",\"functions_emulator_port\",\"functions_emulator_host\"],\"joinArgs\":false}"}}
i  database: Database Emulator logging to database-debug.log {"metadata":{"emulator":{"name":"database"},"message":"Database Emulator logging to \u001b[1mdatabase-debug.log\u001b[22m"}}
[2021-05-20T06:58:27.039Z] 14:58:27.038 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
 {"metadata":{"emulator":{"name":"database"},"message":"14:58:27.038 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started\n"}}
[2021-05-20T06:58:27.176Z] 14:58:27.176 [main] INFO com.firebase.server.forge.App$ - Listening at localhost:9000
 {"metadata":{"emulator":{"name":"database"},"message":"14:58:27.176 [main] INFO com.firebase.server.forge.App$ - Listening at localhost:9000\n"}}
[2021-05-20T06:58:29.503Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"pubsub"},"message":"Ignoring unsupported arg: projectId"}}
[2021-05-20T06:58:29.504Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"pubsub"},"message":"Ignoring unsupported arg: auto_download"}}
[2021-05-20T06:58:29.504Z] Starting Pub/Sub Emulator with command {"binary":"/Users/dennis/.cache/firebase/emulators/pubsub-emulator-0.1.0/pubsub-emulator/bin/cloud-pubsub-emulator","args":["--host=localhost","--port=8085"],"optionalArgs":["port","host"],"joinArgs":true} {"metadata":{"emulator":{"name":"pubsub"},"message":"Starting Pub/Sub Emulator with command {\"binary\":\"/Users/dennis/.cache/firebase/emulators/pubsub-emulator-0.1.0/pubsub-emulator/bin/cloud-pubsub-emulator\",\"args\":[\"--host=localhost\",\"--port=8085\"],\"optionalArgs\":[\"port\",\"host\"],\"joinArgs\":true}"}}
i  pubsub: Pub/Sub Emulator logging to pubsub-debug.log {"metadata":{"emulator":{"name":"pubsub"},"message":"Pub/Sub Emulator logging to \u001b[1mpubsub-debug.log\u001b[22m"}}
[2021-05-20T06:58:29.643Z] This is the Google Pub/Sub fake.
Implementation may be incomplete or differ from the real system.
 {"metadata":{"emulator":{"name":"pubsub"},"message":"This is the Google Pub/Sub fake.\nImplementation may be incomplete or differ from the real system.\n"}}
[2021-05-20T06:58:29.667Z] May 20, 2021 2:58:29 PM com.google.cloud.pubsub.testing.v1.Main main
INFO: IAM integration is disabled. IAM policy methods and ACL checks are not supported
 {"metadata":{"emulator":{"name":"pubsub"},"message":"May 20, 2021 2:58:29 PM com.google.cloud.pubsub.testing.v1.Main main\nINFO: IAM integration is disabled. IAM policy methods and ACL checks are not supported\n"}}
[2021-05-20T06:58:30.043Z] May 20, 2021 2:58:30 PM io.gapi.emulators.netty.NettyUtil applyJava7LongHostnameWorkaround
INFO: Unable to apply Java 7 long hostname workaround.
 {"metadata":{"emulator":{"name":"pubsub"},"message":"May 20, 2021 2:58:30 PM io.gapi.emulators.netty.NettyUtil applyJava7LongHostnameWorkaround\nINFO: Unable to apply Java 7 long hostname workaround.\n"}}
[2021-05-20T06:58:30.126Z] May 20, 2021 2:58:30 PM com.google.cloud.pubsub.testing.v1.Main main
INFO: Server started, listening on 8085
 {"metadata":{"emulator":{"name":"pubsub"},"message":"May 20, 2021 2:58:30 PM com.google.cloud.pubsub.testing.v1.Main main\nINFO: Server started, listening on 8085\n"}}
i  emulators: Shutting down emulators. {"metadata":{"emulator":{"name":"hub"},"message":"Shutting down emulators."}}
i  functions: Stopping Functions Emulator {"metadata":{"emulator":{"name":"functions"},"message":"Stopping Functions Emulator"}}
i  database: Stopping Database Emulator {"metadata":{"emulator":{"name":"database"},"message":"Stopping Database Emulator"}}
[2021-05-20T06:58:30.276Z] 14:58:30.276 [Thread-1] INFO com.firebase.server.forge.App$ - Attempting graceful shutdown.
 {"metadata":{"emulator":{"name":"database"},"message":"14:58:30.276 [Thread-1] INFO com.firebase.server.forge.App$ - Attempting graceful shutdown.\n"}}
[2021-05-20T06:58:30.281Z] 14:58:30.280 [Thread-1] INFO com.firebase.server.forge.App$ - Graceful shutdown complete.
 {"metadata":{"emulator":{"name":"database"},"message":"14:58:30.280 [Thread-1] INFO com.firebase.server.forge.App$ - Graceful shutdown complete.\n"}}
[2021-05-20T06:58:30.355Z] May 20, 2021 2:58:30 PM io.gapi.emulators.grpc.GrpcServer$3 operationComplete
INFO: Adding handler(s) to newly registered Channel.
 {"metadata":{"emulator":{"name":"pubsub"},"message":"May 20, 2021 2:58:30 PM io.gapi.emulators.grpc.GrpcServer$3 operationComplete\nINFO: Adding handler(s) to newly registered Channel.\n"}}
i  firestore: Stopping Firestore Emulator {"metadata":{"emulator":{"name":"firestore"},"message":"Stopping Firestore Emulator"}}
[2021-05-20T06:58:30.647Z] *** shutting down gRPC server since JVM is shutting down
 {"metadata":{"emulator":{"name":"firestore"},"message":"*** shutting down gRPC server since JVM is shutting down\n"}}
[2021-05-20T06:58:30.652Z] *** server shut down
 {"metadata":{"emulator":{"name":"firestore"},"message":"*** server shut down\n"}}
i  pubsub: Stopping Pub/Sub Emulator {"metadata":{"emulator":{"name":"pubsub"},"message":"Stopping Pub/Sub Emulator"}}
[2021-05-20T06:58:31.024Z] *** shutting down gRPC server since JVM is shutting down
 {"metadata":{"emulator":{"name":"pubsub"},"message":"*** shutting down gRPC server since JVM is shutting down\n"}}
[2021-05-20T06:58:31.028Z] *** server shut down
 {"metadata":{"emulator":{"name":"pubsub"},"message":"*** server shut down\n"}}
i  auth: Stopping Authentication Emulator {"metadata":{"emulator":{"name":"auth"},"message":"Stopping Authentication Emulator"}}
i  hub: Stopping emulator hub {"metadata":{"emulator":{"name":"hub"},"message":"Stopping emulator hub"}}

Error: Cannot start the Storage emulator without rules file specified in firebase.json: run 'firebase init' and set up your Storage configuration

Having trouble? Try firebase [command] --help
samtstern commented 3 years ago

Thanks @DennisAlund for the very clear report!

abeisgoat commented 3 years ago

Good catch, will get a patch out this week!

ggirotto commented 3 years ago

Any news on this issue?

agbizzzle commented 3 years ago

@samtstern @abeisgoat Can you please provide an ETA on this? It's a blocker for deployments. Thanks.

LucyEgan commented 3 years ago

@samtstern @abeisgoat Is there a ETA on this yet? Currently a blocker for fully using the emulator for us too. Thanks

riordanpawley commented 3 years ago

@BunFluffpaws Can't remember where i found this fix but you can alter the storage config in firebase.json after the emulator is running to get around this issue.

E.g. https://gist.github.com/riordanpawley/cd9595cce7a3ee59e35a3b0a5ca62f0b

LucyEgan commented 3 years ago

@riordanpawley Thanks, I ended up working around this by having both buckets security rules in a single file over using the wildcards, only problem though is this gets deployed to 3 env's so 6 rules for 2 buckets :D but hey.

Ive only had a quick read over the code you supplied, does it trick the emulator into only running 1 bucket or do they all still get their security rules applied?

huyhn310 commented 2 years ago

@BunFluffpaws Can you tell more about your workaround?

LucyEgan commented 2 years ago

@huyhn310 in your storage.rules have multiple buckets matching in the single rules file, the emulator will use it for all of them in a single file, then you can read/write to those extra buckets you create on the fly though using them in the emulator. it doesnt work for deploying them via firebase cli, but we dont manage the buckets via that just though the web console directly.

Its not nice but it worked for being able to use the emulator.

` rules_version = '2'; service firebase.storage {

//default bucket match /b/*.appspot.com/o { match /{allPaths=**} { allow read: if false; allow write: if false; } }

//next bucket match /b/your-other-bucket-s/o { match /{allPaths=**} { allow read; }

match /{accountId}/{allPaths=**} {
  allow write: if request.auth != null && request.auth.uid == accountId;
}

} } `

jhu7235 commented 2 years ago

@abeisgoat is this still being worked on? We're still waiting for fix.

huyhn310 commented 2 years ago

Dear Jason,

Sorry for the late reply, I missed your email. I am checking on it now.

Thanks & Best Regards, HuyHN

On Wed, 6 Oct 2021 at 17:09, Jason Hu @.***> wrote:

@abeisgoat https://github.com/abeisgoat is this still being worked on? We're still waiting for fix.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-tools/issues/3390#issuecomment-935898270, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANU3OLXA7HOY32TQFBHGQLTUFQN4DANCNFSM45GFWERA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

DanKaplanSES commented 2 years ago

Any other workarounds?

tran-simon commented 2 years ago

This is blocking for me too

jowo-io commented 2 years ago

same here, blocking

ittaboba commented 2 years ago

I am blocked too. Could you please fix?

tonyjhuang commented 2 years ago

Hi all, thanks for your patience. @tohhsinpei is working on a fix to this issue, it should be included in either our upcoming release or the one following. Stay tuned for updates.

ggirotto commented 2 years ago

Hey there, what's the difference between using targets and bucket? I was using the configuration file as

"storage": [
...
{
      "rules": "backup_storage.rules",
      "bucket": "backup-bucket"
    }
]

But it doesn't work because the Storage emulator requires a target set:

Error: Must supply 'target' in Storage configuration

tohhsinpei commented 2 years ago

@ggirotto A single target may identify multiple buckets. Please use the target key in your firebase.json file in accordance with the CLI docs.

ittaboba commented 2 years ago

Hi, thanks for the fix.

Since the update, I get the following error given the same previous working code whether it is single or multiple rules configuration:

FirebaseError: Firebase Storage: User does not have permission to access '...' (storage/unauthorized) {"error":{"code":403,"message":"Permission denied. Storage Emulator has no loaded ruleset."}}

ittaboba commented 2 years ago

I also get this error if I go back to my default storage rules only (previously working):

FirebaseError: Firebase Storage: An unknown error occurred, please check the error payload for server response. (storage/unknown)

Tried to follow this thread with no success https://stackoverflow.com/questions/70052479/firebase-storage-an-unknown-error-occurred-please-check-the-error-payload-for

Please, help

tohhsinpei commented 2 years ago

@ittaboba Could you provide the full contents of your firebase.json file (the one with multiple targets)? When do you get the permissions error – on start?

ittaboba commented 2 years ago

Here's my firebase.json:

{
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ],
    "source": "functions"
  },
  "emulators": {
    "functions": {
      "port": 5001
    },
    "ui": {
      "enabled": true,
      "port": 4000
    },
    "auth": {
      "port": 9099
    },
    "storage": {
      "port": 9199
    },
    "database": {
      "port": 9000
    }
  },
  "database": {
    "rules": "database.rules.json"
  },
  "storage": [
    {
      "rules": "storage.rules",
      "target": "default-bucket"
    },
    {
      "rules": "storage-import-docs.rules",
      "target": "import-bucket"
    }
  ]
}

I get permission error on upload on both buckets.

I think it's related to this issue #4346

tohhsinpei commented 2 years ago

Ok, I'll take a look. Thanks for the report.

tonyjhuang commented 2 years ago

Reopening for now until this is resolved

tonyjhuang commented 2 years ago

filed internal bug to track, b/240331248

abhis3 commented 2 years ago

Hey there, I took a look into it and wasn't able to repro this issue using the firebase.json that you provided. In addition, it seems that all the linked issues (#4326, etc) are closed out and we have integration tests that specifically test for the storage emulator accepting multiple targets.

We recommend upgrading to the latest version of the emulator as we've made a lot of fixes and stability improvements over the past months.

Closing out this issue as we believe it's resolved, please feel free to reach out and reopen with a sample app repro-ing the issue on the latest emulator version if you are still encountering it and we'll gladly take look.

paymog commented 2 years ago

@abhis3 this doesn't seem to work for a storage configuration with multiple buckets like so:

  "storage": [
    {
      "rules": "firebase-config/private-storage.rules",
      "bucket": "lookieloo-app.appspot.com"
    },
    {
      "rules": "firebase-config/public-storage.rules",
      "bucket": "lookieloo-app-public"
    }
  ],

I'm using firebase version 11.6

 ❯❯❯ firebase --version
11.6.0

I took a look at these docs which mention setting up a target using site IDs for hosting, but my firebase project doesn't use hosting at all.

tonyjhuang commented 2 years ago

Hi @paymog please see https://firebase.google.com/docs/cli/targets#set-up-deploy-target-storage-database for examples on how to setup your firebase.json file to support different rules for different buckets.

You'll likely have to have a set up similar to the following:

"storage": [
    {
      "rules": "firebase-config/private-storage.rules",
      "target": "default"
    },
    {
      "rules": "firebase-config/public-storage.rules",
      "target": "public"
    }
  ]

Set up your targets like so:

$ firebase target:apply storage default <default bucket>
# etc
paymog commented 2 years ago

that worked, thank you for the incredibly quick response!

Padreco-lbr commented 1 year ago

I am running firebase-tools version 11.25.2 under Windows and the behavior is exactly the same as described by OP.

Already set the target on firebase.json:

 "storage": [
...
{
"target": "default",
"rules": "<path/to/my/rules>"
}

And added the target on firebase tools: firebase target:apply storage default <default bucket>

akashdeep-sarin commented 9 months ago

I am getting this error too... my default bucket it is using the emulator location, but for my second bucket it is always hitting the cloud bucket at https://firebasestorage.googleapis.com/v0/b/*****

I have tried following the instructions given in https://stackoverflow.com/questions/68340724/how-do-i-create-additional-buckets-in-firebase-cloud-storage-emulator https://firebase.google.com/docs/cli/targets#set-up-deploy-target-storage-database multiple times, but nothing works...

Also the while(incorrectly) sending the file to firebase the security rule for 2nd bucket fails, probably it sends incorrect authentication to firebase.

blikblum commented 3 months ago

@akashdeep-sarin i've managed to fix using this tip: https://stackoverflow.com/a/77936073/5724645

In fact, since i use the namespace sdk the code is:

  firebase.storage().useEmulator('localhost', 9199)
  // with modular api is possible to connect to a second bucket https://stackoverflow.com/a/77936073/5724645
  // with the namespaced api it's a little different
  const waMediaAssetsBucket = 'xxx'
  firebase.app().storage(waMediaAssetsBucket).useEmulator('localhost', 9199)