如何从index.ts分别导出firebase cloud函数2GEN?

发布于 2025-02-10 19:03:01 字数 875 浏览 1 评论 0原文

我正在尝试通过以下此文档将特定的云功能更新为第二代: https:https:// https:// firebase .google.com/docs/functions/beta 它说

“支持使用functions.config()的环境配置的支持 已从Firebase V2的云功能中删除。 functions.config() 被环境变量替换。”

函数,我必须为v1函数运行functions.config()。

export { my1GenFunction} from "./my_first_gen_function";
export { my2GenFunction} from "./my_second_gen_function";

admin.initializeApp(functions.config().firebase);

...

但是,当我尝试用<<<代码> functions.config(),我正在得到云运行错误

用户提供的容器无法在端口上启动和侦听 由端口= 8080环境变量定义。为此记录 修订可能包含更多信息。

检查修订日志告诉我:

错误:functions.config()在云功能中不再可用 对于firebase v2。请参阅最新文档以获取信息 关于如何过渡到使用环境变量

是否可以将这些出口分开?

谢谢!

I am trying to update a specific cloud function to 2nd gen by following this documentation : https://firebase.google.com/docs/functions/beta
and it says

"Support for Environment Configuration with functions.config() has
been removed from Cloud Functions for Firebase v2. functions.config()
is replaced by environment variables."

The problem is, that my index.ts file exports v1 and v2 functions and I have to run functions.config() for the v1 functions.

export { my1GenFunction} from "./my_first_gen_function";
export { my2GenFunction} from "./my_second_gen_function";

admin.initializeApp(functions.config().firebase);

...

However, when I try to deploy the v2 function with the functions.config(), I am getting a Cloud Run Error

The user-provided container failed to start and listen on the port
defined provided by the PORT=8080 environment variable. Logs for this
revision might contain more information.

Checking the revision log tells me:

Error: functions.config() is no longer available in Cloud Functions
for Firebase v2. Please see the latest documentation for information
on how to transition to using environment variables

Is there a way to split those exports?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

靑春怀旧 2025-02-17 19:03:01

在您的代码中,您可能没有收听传入的HTTP请求,您是否有端口80的ENV变量?这样的事情:

const port = process.env.PORT || 8080;
app.listen(port, () => {
    console.log('Hello world listening on port', port);
});

In your code probably you aren't listening to incoming HTTP requests, do you have an env variable for the port 80? something like this:

const port = process.env.PORT || 8080;
app.listen(port, () => {
    console.log('Hello world listening on port', port);
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文