Firebase"访问字体"错误

时间:2018-03-19 17:17:00

标签: firebase cors firebase-hosting

这可能是一种疏忽,但我使用了firebase并设置了firebase.json文件,该文件是自动生成和从Firebase的文档中复制标题块的混合体。问题是,我的字体拒绝允许我访问,即使我的文件看起来像这样:

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "hosting": {
    "public": "build",
    "ignore": [
    "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ],
    "headers": [
      {
        "source" : "**/*.@(eot|otf|ttf|ttc|woff)",
        "headers" : [{
          "key" : "Access-Control-Allow-Origin",
          "value" : "*"
        }]
      }, {
        "source" : "**/*.@(jpg|jpeg|gif|png|svg)",
        "headers" : [{
          "key" : "Cache-Control",
          "value" : "max-age=7200"
      }]
    }]
  },
  "storage": {
    "rules": "storage.rules"
  }
}

这是我得到的CORS错误:

Access to Font {Firebase font url}. {Firebase font url} from origin {Firebase project url} has been blocked by CORS policy. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin {Firebase project url} is therefore not allowed access.

旁注:我有一个图像文件夹,我可以在其中加载那些就好了。是否需要更多关注字体呢?

1 个答案:

答案 0 :(得分:0)

Firebase推出了一项新功能/工具,迫使用户更新Google存储空间的CORS设置。我在StackOverflow问题上找到了答案。 Firebase Storage and Access-Control-Allow-Origin