gpt4 book ai didi

firebase - 如何在 Firebase 文件上设置 Access-Control-Allow-Origin

转载 作者:行者123 更新时间:2023-12-02 22:01:59 26 4
gpt4 key购买 nike

我正在尝试将某个文件的 Access-Control-Allow-Origin 设置为 *

这是我的 firebase.json 文件:

{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "public",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"headers": [ {
"source" : "bundle.js",
"headers" : [ {
"key" : "Access-Control-Allow-Origin",
"value" : "*"
} ]
}]
}

但是它永远不会被设置:https://curious-athlete-131013.firebaseapp.com/bundle.js

最佳答案

尝试将 header 嵌套在托管下方,而不是作为它自己的顶级节点:

{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "public",
"rewrites": [{
"source": "**",
"destination": "/index.html"
}],
"headers": [{
"source" : "bundle.js",
"headers" : [{
"key" : "Access-Control-Allow-Origin",
"value" : "*"
}]
}]
}
}

“可以通过在 firebase.json 文件中托管中定义 header 部分来指定自定义、文件特定的 header :” - Firebase Docs

关于firebase - 如何在 Firebase 文件上设置 Access-Control-Allow-Origin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38151896/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com