我正在尝试设置Access-Control-Allow-Origin
to *
在某个文件上。
这是我的 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 https://curious-athlete-131013.firebaseapp.com/bundle.js
尝试将标头嵌套在托管下方,而不是作为它自己的顶级节点:
{
"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 文件中:” -Firebase 文档 https://firebase.google.com/docs/hosting/url-redirects-rewrites
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)