gpt4 book ai didi

reactjs - Firebase - 预检响应中的 Access-Control-Allow-Headers 不允许请求 header 字段 x-firebase-gmpid

转载 作者:行者123 更新时间:2023-12-03 13:29:11 25 4
gpt4 key购买 nike

我的产品使用 firebase rtdb、firestore、存储、身份验证和托管。我没有对 CORS 配置进行任何更改。然而,今天我在尝试将图像上传到存储并检索它们时开始收到以下 CORS 错误:

Access to XMLHttpRequest at 'https://firebasestorage.googleapis.com/v0/b/diary-a77f6.appspot.com/o?name=images%2FJ1gU3KPfo1cTHJXhT3iopBqrvVs1%2F-M1Ah4xCQ46GvEZtwgR1%2FBalboa%20Pier%2C%20California%20-%201600x1200%20-%20ID%2027253.jpg' from origin 'https://daybook.app' has been blocked by CORS policy: Request header field x-firebase-gmpid is not allowed by Access-Control-Allow-Headers in preflight response.

我试过Firebase Storage and Access-Control-Allow-Origin , https://cloud.google.com/storage/docs/configuring-cors ,和https://firebase.google.com/docs/storage/web/download-files#cors_configuration无济于事。

我的托管配置:

{
"target": "prod",
"public": "build/production",
"ignore": [
"firebase.json",
"src/firebase/keys.js",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"headers": [
{
"source": "/**",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache, no-store, must-revalidate"
},
{
"key": "Access-Control-Allow-Headers",
"value": "x-firebase-gmpid, Origin, Accept, Content-Type, X-Requested-With, Access-Control-Request-Method,Access-Control-Request-Headers, Authorization"
}
]
},
{
"source": "**/*.@(css|js)",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache, no-store, must-revalidate max-age=0"
}
]
},
{
"source": "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
"headers": [
{
"key": "Access-Control-Allow-Origin",
"value": "*"
}
]
},
{
"source": "**/*.@(jpg|jpeg|gif|png|webp|webp|svg)",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=7200"
}
]
}
]
}

这是我最近在尝试解决问题时添加的内容:

{
"key": "Access-Control-Allow-Headers",
"value": "x-firebase-gmpid, Origin, Accept, Content-Type, X-Requested-With, Access-Control-Request-Method,Access-Control-Request-Headers, Authorization"
}

最佳答案

我认为这是 Firestore JS 客户端库的问题。我将其从 7.9.2 版本回滚到 7.9.0 版本,错误消失了。

编辑:7.9.3 包含修复程序。

关于reactjs - Firebase - 预检响应中的 Access-Control-Allow-Headers 不允许请求 header 字段 x-firebase-gmpid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60456895/

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