Firebase-在飞行前响应中Access-Control-Allow-Headers不允许请求标头字段x-firebase-gmpid [英] Firebase - Request header field x-firebase-gmpid is not allowed by Access-Control-Allow-Headers in preflight response
问题描述
我的产品使用Firebase rtdb,firestore,存储,身份验证和托管。
我没有对CORS配置进行任何更改。但是,今天,当我尝试将图像上传到存储并检索它们时,我开始出现以下CORS错误:
My product uses firebase rtdb, firestore, storage, auth, and hosting. I didn't make any changes to my CORS configuration. However, today I started getting the following CORS error while trying to upload images to storage, and retrieve them:
在'< a href = https://firebasestorage.googleapis.com/v0/b/diary-a77f6.appspot.com/o?name=images%2FJ1gU3KPfo1cTHJXhT3iopBqrvVs1%2F-M1Ah4xCQ46GvEZtwgR1%2FBalfornia%%Cier-20%Cier %20-%20ID%2027253.jpg rel = noreferrer> https://firebasestorage.googleapis.com/v0/b/diary-a77f6.appspot.com/o?name=images%2FJ1gU3KPfo1cTHJXhT3iopBqrvVs1%2F-M1AhvxC 2FBalboa%20Pier%2C%20California%20-%201600x1200%20-%20ID%2027253.jpg '源自来源 >: //daybook.app 已被CORS政策阻止:飞行前响应中Access-Control-Allow-Headers不允许请求标头字段x-firebase-gmpid。
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存储和访问控制允许来源,
https://cloud.google.com/storage/docs/configuring-cors 和 https://firebase.google.com/docs/storage/web/download-files#cors_configuration 无济于事。
I tried Firebase Storage and Access-Control-Allow-Origin, https://cloud.google.com/storage/docs/configuring-cors, and https://firebase.google.com/docs/storage/web/download-files#cors_configuration to no avail.
我的托管配置:
{
"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"
}
]
}
]
}
这是我最近添加的内容e尝试解决此问题:
This is what I added recently while trying to fix the issue:
{
"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
,错误消失了。
I think this was an issue with the Firestore JS client library. I rolled it back to version 7.9.0
from version 7.9.2
and the error went away.
编辑:7.9.3包含此修复程序。
edit: 7.9.3 contains the fix.
这篇关于Firebase-在飞行前响应中Access-Control-Allow-Headers不允许请求标头字段x-firebase-gmpid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!