我的产品使用 firebase rtdb、firestore、storage、auth 和托管。我没有对我的 CORS 配置进行任何更改。但是,今天我在尝试将图像上传到存储并检索它们时开始收到以下 CORS 错误:
访问 XMLHttpRequest ' https://firebasestorage.googleapis.com/v0/b/diary-a77f6.appspot.com/o?name=images%2FJ1gU3KPfo1cTHJXhT3iopBqrvVs1%2F-M1Ah4xCQ46GvEZ2%2FPalwa1%2%2P0aCalifor%20P0aCalifor% 201600x1200%20-%20ID%2027253.jpg ' from origin ' 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, …Run Code Online (Sandbox Code Playgroud) 最近,我尝试将我的 firebase 云函数从 javascript 迁移到 typescript,并将这些函数拆分为多个文件。但是,在尝试提供服务和部署时,我不断收到错误消息:
服务时的错误:
函数[functionName]:函数被忽略,因为 Firestore 模拟器不存在或未运行。函数[functionName]:函数被忽略,因为 firebase 模拟器不存在或未运行。
部署时出错:
functions[dataDownload(us-central1)]: Deployment error.
Function failed on loading user code. Error message: Code in file lib/index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: /srv/node_modules/fs-extra/lib/mkdirs/make-dir.js:86
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at …Run Code Online (Sandbox Code Playgroud)