reactjs - Firebase - 预检响应中的 Access-Control-Allow-Headers 不允许请求标头字段 x-firebase-gmpid
问题描述
我的产品使用 firebase rtdb、firestore、storage、auth 和 hosting。我没有对我的 CORS 配置进行任何更改。但是,今天我在尝试将图像上传到存储并检索它们时开始收到以下 CORS 错误:
在' https://firebasestorage.googleapis.com/v0/b/diary-a77f6.appspot.com/o?name=images%2FJ1gU3KPfo1cTHJXhT3iopBqrvVs1%2F-M1Ah4xCQ46GvEZtwgR1%2FBalboa%20Pier%2C%20California%20-%访问 XMLHttpRequest 201600x1200%20-%20ID%2027253.jpg '来自来源' https://daybook.app ' 已被 CORS 策略阻止:预检中的 Access-Control-Allow-Headers 不允许请求标头字段 x-firebase-gmpid回复。
我尝试了 Firebase Storage 和 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.0
我将它从版本回滚到版本7.9.2
并且错误消失了。
编辑:7.9.3 包含修复。
推荐阅读
- linux - 非阻塞套接字与 select() 驱动方法
- android - 如何使用 EditText 为 android 应用程序的回收器视图提供搜索功能?
- php - PHP数组到CSV输出整个html页面
- java - 使用 Mockito 和 Spring Boot 进行深度模拟
- azure - Azure Functions:查询终结点会引发错误 500.37 - ANCM 无法在启动时间限制内启动
- amazon-web-services - 与另一个账户共享 AWS 托管 KMS 密钥
- java - 多个线程上的 Spring Transaction
- javascript - 如何在 javascript 中增加 onmouseover 事件的转换时间?
- haskell - 为字典实现 Applicative 实例(映射、关联数组)
- c# - 具有继承的专业化和专门的方法返回的流利的构建器(奇怪的重复模板)