Search code examples
firebasefirebase-storagefirebase-tools

CORS and firebase storage emulator


I am using firebase and uploading files successfully to storage in an actual firebase project but when I try and use the storage emulator I can see the upload requests fail with CORS errors.

I am using the web v9 sdk and doing something pretty simple using uploadBytes as described in the docs

In order to get it working without the emulator I had to configure CORS for my buckets and that seems to be fine. For now they are both configured like [{"maxAgeSeconds": 3600, "method": ["GET", "POST"], "origin": ["http://localhost:3000"]}]. I guess I need to do something similar when using the emulator but I am unclear exactly what or how..

The firebase docs say

The Cloud Storage emulator does not support any bucket-level configuration including storage class, bucket-level CORS configuration, labels, or retention policies. Firebase intends to improve this support over time.

But surely that doesn't mean it is not possible to upload files to the emulator using the web sdk at all? What am I doing wrong?


Solution

  • I had the emulator port misconfigured and was thrown by the error talking about CORS, it works fine now