标签: firebase-cli

如何从 firebase 函数中的“获取请求”获取参数?

我知道 firebase https.onRequest 中的请求参数对应于 Express 响应。

我想使用这种格式运行云函数(本地测试):

http://localhost:5000/test-2c6e8/us-central1/coins?userid=1
Run Code Online (Sandbox Code Playgroud)

所以,现在我只想从云函数获取 userId 参数。我写的测试函数是:

exports.coins = functions.https.onRequest((request, response) => 
{
    var db = admin.firestore();
    response.json({query: JSON.stringify(request.query),
                   params: JSON.stringify(request.params),
                   body: JSON.stringify(request.body)});
    response.end();
});
Run Code Online (Sandbox Code Playgroud)

这是我得到的输出:

query   "{}"
params  "{\"0\":\"\"}"
body    "{}"
Run Code Online (Sandbox Code Playgroud)

我尝试了很多事情但没有任何运气。为什么会发生这种情况?

node.js firebase google-cloud-functions firebase-cli

3
推荐指数
1
解决办法
4039
查看次数

Firebase 项目初始化错误:无法列出可用的 Google Cloud Platform 项目

我正在尝试设置一个 Ionic 应用程序来使用现有的 Firebase 项目,Firebase init在 Windows 控制台中运行时我收到以下消息:

Error: Failed to list available Google Cloud Platform projects. See firebase-debug.log for more info.

日志显示访问服务器时出现 401 错误。

firebase firebase-cli

3
推荐指数
1
解决办法
2697
查看次数

使用 firestore 命令获取所有 firestore 安全规则

我正在为 firebase 创建一个部署脚本,其中获取 firestore 的所有索引和安全规则,然后保存在我的 firestore.indexes/rules.json 中,然后切换和部署项目。我知道如何从 firebase“ firebase firestore:indexes > save.json ”读取规则,它将获取我的 firestore 中的所有索引并保存它,但无法获取如何在本地文件中提取所有 firestore 规则

谁能帮我解决这个问题

firebase google-cloud-firestore firebase-cli

3
推荐指数
1
解决办法
990
查看次数

如何以非交互方式安装 firebase 扩展

我正在尝试通过安装 firebasefirestore-bigquery-export扩展firebase CLI。但我找不到如何安装扩展的non-interactive方式。

我需要它,因为我有多个环境和 CI。

控制台包含有关 的信息,但在哪里可以找到参数名称?

$ firebase ext:install firestore-bigquery-export -h
Usage: firebase ext:install [options] [extensionName]

install an official extension if [extensionName] or [extensionName@version] is provided; or run with `-i` to see all available extensions.

Options:
  --params <paramsFile>  name of params variables file with .env format.
  -h, --help             output usage information
Run Code Online (Sandbox Code Playgroud)

感谢您的帮助!

firebase google-bigquery firebase-cli firebase-extensions

3
推荐指数
1
解决办法
1080
查看次数

Firebase 模拟器无法启动并出现无意义的错误

我们使用模拟器已经有一段时间了。突然,他们停止在两个开发人员(但不是所有开发人员)的机器上工作。他们尝试调用firebase emulators:start,然后收到以下错误消息:Error: An unexpected error has occurred.

\n

我们真的不知道为什么会发生这种情况。我们甚至尝试重做 firebase init 和 emulators init。到目前为止,我们所做的一切尝试都没有帮助。以下是控制台输出以了解更多详细信息:

\n
\xe2\x9e\x9c  firebase git:(dev-vab) \xe2\x9c\x97 firebase emulators:start\ni  emulators: Starting emulators: functions, firestore, database, hosting, pubsub\n\xe2\x9a\xa0  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth\n\xe2\x9a\xa0  Your requested "node" version "10" doesn't match your global version "14"\ni  firestore: Firestore Emulator logging to firestore-debug.log\ni  database: Database Emulator logging to database-debug.log\ni  hosting: Serving hosting files from: public\n\xe2\x9c\x94 …
Run Code Online (Sandbox Code Playgroud)

firebase firebase-cli

3
推荐指数
1
解决办法
4980
查看次数

错误:hosting:channel:deploy 不是 Firebase 命令

我正在尝试预览我的 firebase 网站并使用以下命令共享:

firebase hosting:channel:deploy "testing_changes" 
Run Code Online (Sandbox Code Playgroud)

但我不断得到 Error: hosting:channel:deploy is not a Firebase command

我也试过不传递字符串而只传递单词,但我得到了同样的错误。我很确定我在根目录中。

firebase firebase-hosting firebase-cli

3
推荐指数
1
解决办法
581
查看次数

Firebase 功能部署未更新

我在多个文件中设置了 firebase 函数。由于某种原因,当我部署时,更改不会被应用,就好像它们被缓存或其他什么一样。

我的文件夹结构如下:

功能/

SCR/

index.ts
auth.ts
inventory.ts
Run Code Online (Sandbox Code Playgroud)

这是我的index.ts:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const functions = require("firebase-functions");
const admin = require("firebase-admin");
exports.auth = require("./auth");
exports.inventory = require("./inventory");
admin.initializeApp();
Run Code Online (Sandbox Code Playgroud)

授权.ts:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const auth_functions = require("firebase-functions");
exports.login = auth_functions.https.onRequest(
  (request: any, response: any) => {
    response.send("login");
  }
);

exports.logout = auth_functions.https.onRequest(
  (request: any, response: any) => {
    response.send("logout");
  }
);
Run Code Online (Sandbox Code Playgroud)

库存.ts

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const …
Run Code Online (Sandbox Code Playgroud)

firebase typescript google-cloud-functions firebase-cli

3
推荐指数
1
解决办法
1337
查看次数

如何禁用 Firebase 存储模拟器?

当我启动模拟器时,存储模拟器将启动并可在localhost:9199上使用。
然后我使用 node.js 中的管理 SDK 访问存储:

serviceAccountKey = require('./serviceAccountKey.json');
const config = {
  credential: admin.credential.cert(serviceAccountKey),
};
const adminApp = admin.initializeApp(config);
const storage = adminApp.storage();
Run Code Online (Sandbox Code Playgroud)

现在存储指向模拟器,而不是像该模拟器实现之前那样指向真正的服务。
如何才能获得真正的服务?
我已尝试按照此处所述设置projectId和 env 变量,但它不起作用。

firebase firebase-storage firebase-cli

3
推荐指数
1
解决办法
2204
查看次数

如何列出当前保存的所有 firebase 功能配置?

有没有办法列出我使用以下命令保存的所有密钥,以检查我想要在出现任何问题时删除的密钥或仅供参考?

firebase functions:config:set
Run Code Online (Sandbox Code Playgroud)

google-cloud-functions firebase-cli

3
推荐指数
1
解决办法
3242
查看次数

使用带有GET的查询字符串在本地测试Firebase HTTP Cloud功能

我在Firebase上具有HTTP Cloud功能。我可以在没有查询字符串的情况下使用GET方法成功调用本教程之后的函数。

> test.get() 
Run Code Online (Sandbox Code Playgroud)

我的问题是如何使用查询字符串测试HTTP函数?如何将其传递给调用调用?

我在外壳上尝试过

> test.get({"name":"test"})
Run Code Online (Sandbox Code Playgroud)

在我的index.js上,我尝试打印名称:

exports.test= functions.https.onRequest((req, res) => {
    console.log(req.query.name);
});
Run Code Online (Sandbox Code Playgroud)

它不起作用,返回了undefined

testing node.js firebase google-cloud-functions firebase-cli

2
推荐指数
1
解决办法
994
查看次数