Access-Control-Allow-Origin已添加到firebase.json,但在文件响应标头中丢失 [英] Access-Control-Allow-Origin added to firebase.json but missing from the file response header

查看:56
本文介绍了Access-Control-Allow-Origin已添加到firebase.json,但在文件响应标头中丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我简单的firebase.json.如果我没看错文档,应该用"Access-Control-Allow-Origin"标记所有文件.不幸的是,没有文件被标记导致错误:

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:

从来源" https://gaspush.firebaseapp.com 导入的资源具有 已被跨域资源共享策略阻止加载:否 请求中存在"Access-Control-Allow-Origin"标头 资源.

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/**"
  ]
}

推荐答案

这可能与原始问题不再相关,但是我在新版本的Firebase中遇到了类似的问题.我不小心将"headers"部分放在了"hosting"键之外.

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" : "*"
        }]
    }]
  }

这篇关于Access-Control-Allow-Origin已添加到firebase.json,但在文件响应标头中丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆