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、storage、auth 和 hosting.我没有对我的 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:
在 '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'来自原点'https://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 存储和 Access-Control-Allow-Origin,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"
}
]
}
]
}
这是我最近在尝试解决问题时添加的:
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屋!