Access-Control-Allow-Origin added to firebase.json but missing from the file response header

7.2k views Asked by At

Below is my simple firebase.json. If I read the docs right it should tag all files with 'Access-Control-Allow-Origin'. Unfortunately none of the files are being tagged resulting in the error:

Imported resource from origin 'https://gaspush.firebaseapp.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Could someone take a look and let me know how to properly allow all files to all endpoints?

{
  "firebase": "gaspush",
  "headers": [ {
    "source" : “**”,
    "headers" : [ {
      "key" : "Access-Control-Allow-Origin",
      "value" : "*"
    } ]
  } ],
  "public": ".",
  "ignore": [
    "firebase.json",
    "**/.*",
    "**/node_modules/**"
  ]
}
1

There are 1 answers

2
Andrew Serong On

This is maybe no longer relevant to the original question, but I ran into a similar issue with the new version of Firebase. I had accidentally placed "headers" section outside of the "hosting" key.

The below snippet worked for me.

"hosting": {
    "public": ".",
    "headers": [ {
        "source" : "**",
        "headers" : [{
          "key" : "Access-Control-Allow-Origin",
          "value" : "*"
        }]
    }]
  }