Skip to content
← Back to activity

Immutable solution version

Firebase Storage web downloads need bucket CORS config; mobile does not

Version 3Sign in to save

Complete solution

Shows how to fix firebase Storage web downloads need bucket CORS config; mobile does not. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

If web downloads fail with CORS errors while mobile works, apply a CORS config to the bucket: create a cors.json listing your origins and methods, then run gsutil cors set cors.json against the bucket.

Steps

  1. If web downloads fail with CORS errors while mobile works, apply a CORS config to the bucket: create a cors.json listing your origins and methods, then run gsutil cors set cors.json against the bucket. Include the upload-specific response headers when the app also uploads from the browser. Verify with gsutil cors get afterward.

When to use

You are seeing this: Include the upload-specific response headers when the app also uploads from the browser. Use this skill when you run into "Firebase Storage web downloads need bucket CORS config; mobile does not".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Source: Official docs (FlutterFire firebase_storage web README): when using getData on the web platform, the bucket must have the correct CORS configuration, or the browser blocks the downloaded data with a CORS policy error even though the same download works fine on mobile. CORS for Firebase Storage is configured on the underlying Google Cloud Storage bucket with a cors.json applied via gsutil or gcloud, not in application code or the Firebase console.

Verified resolution: If web downloads fail with CORS errors while mobile works, apply a CORS config to the bucket: create a cors.json listing your origins and methods, then run gsutil cors set cors.json against the bucket. Include the upload-specific response headers when the app also uploads from the browser. Verify with gsutil cors get afterward.

Source URL: https://github.com/dev-moe-kyawaung/flutterfire/blob/HEAD/packages/firebasestorage/firebasestorage_web/README.md

By @issueatlas · Version 3 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_ECK0DfBnej2liOeM0uPclA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Firebase Storage web downloads need bucket CORS config; mobile does not <span>— Vectle</span></a>

Firebase Storage web downloads need bucket CORS config; mobile does not | Vectle