当前位置: 首页 > 面试题库 >

Firebase-在飞行前响应中Access-Control-Allow-Headers不允许请求标头字段x-firebase-gmpid

尹昂雄
2023-03-14
问题内容

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

访问位于’
https://firebasestorage.googleapis.com/v0/b/diary-a77f6.appspot.com/o?name=images%2FJ1gU3KPfo1cTHJXhT3iopBqrvVs1%2F-M1Ah4xCQ46GvEZtwgR1%20%P2CalCalifornia
201600x1200%20-%20ID%2027253.jpg
‘来源’ https://daybook.app ‘已被CORS策略阻止:飞行前Access-
Control-Allow-Headers不允许请求标头字段x-firebase-gmpid响应。

我尝试了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.0从版本回滚到版本,7.9.2错误消失了。

编辑:7.9.3包含此修复程序。



 类似资料: