【问题标题】:Firebase Storage CORS error while uploading file from Vue webapp [duplicate]从Vue webapp上传文件时Firebase Storage CORS错误[重复]
【发布时间】:2020-06-12 08:38:20
【问题描述】:

我正在尝试使用此代码从 vue webapp 上传 pdf 文件

let storageRef = firebase.storage().ref();
let uploadTask = storageRef.child("results").put(file);

当我在控制台中选择文件时,我看到了这个错误。

(Reason: header ‘x-firebase-gmpid’ is not allowed according to header ‘Access-Control-Allow-Headers’ from CORS preflight response)

我尝试通过 gsutil 设置 cors 配置

[
  {
    "origin": ["*"],
    "responseHeader": ["Content-Type"],
    "method": ["GET", "HEAD", "DELETE"],
    "maxAgeSeconds": 3600
  }
]

仍然遇到同样的错误。

【问题讨论】:

  • 更新 gsutil 配置以拥有 "responseHeader": ["Content-Type", "x-firebase-gmpid"]
  • 还是同样的错误。添加不会解决问题,因为标题“x-firebase-gmpid”是不允许的

标签: firebase vue.js cors


【解决方案1】:

这是最新的 firebase js 版本 v7.9.2 中的一个错误。如果您将 firebase 降级到 v7.9.1,错误就会消失。

【讨论】:

    猜你喜欢
    • 2015-02-01
    • 2022-01-23
    • 1970-01-01
    • 2014-10-23
    • 2018-12-26
    • 2019-04-08
    • 2020-08-28
    • 2017-05-09
    • 2021-04-16
    相关资源
    最近更新 更多