title: Enabling CORS on Firebase Storage for localhost tests
body: <p>My web app will run on Firebase Hosting, but I need to test it locally through <code>firebase serve</code> on <code>localhost:5000</code>
  I am incurring in a CORS error while trying to read a file on Firebase Storage.</p>
  
  <p>I have followed <a href="https://firebase.google.com/docs/hosting/full-config#headers" rel="nofollow noreferrer">documentation</a>, and added the relative heading section to firebase.json:</p>
  
  <pre><code>{
    "firestore": {
      "rules": "firestore.rules",
      "indexes": "firestore.indexes.json"
    },
    "hosting": {
      "public": "public",
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
    "headers": [ {
        "source": "**",
        "headers": [ {
          "key": "Access-Control-Allow-Origin",
          "value": "*"
        } ]
      }]
    },
    "storage": {
      "rules": "storage.rules"
    }
  }
  </code></pre>
  
  <p>But this didn't fix. I am still blocked on CORS error.</p>
  
  <p><strong>EDIT with solution</strong></p>
  
  <p>I have fixed this by using the python library and a short script:</p>
  
  <pre><code>#!/usr/bin/env python3
  
  import firebase_admin
  from firebase_admin import credentials
  from firebase_admin import storage
  
  
  CREDFILE = home + 'credentials.json'
  cred = credentials.Certificate(CREDFILE)
  firebase_admin.initialize_app(cred, {
      'storageBucket': '&lt;myapp&gt;.appspot.com'
  })
  bucket = storage.bucket()
  
  bucket.cors = [{
    'origin': ['*'],
    'method': ['GET'],
    'maxAgeSeconds': 86400
  }]
  
  bucket.update()
  </code></pre>