You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firebase Functions集成Express遇TypeError: handler is not a function问题

解决方案

问题出在你配置minInstances的方式不对——minInstances属于Firebase Functions的运行时实例配置,不能直接作为functions.https.onRequest()的第一个参数传入。

正确的写法是通过functions.runWith()来指定运行时选项,再链式调用https.onRequest():

exports.myFunction = functions.runWith({ minInstances: 2 }).https.onRequest(app);

错误原因

你之前的代码functions.https.onRequest({minInstances: 2}, app)里,第一个参数被onRequest方法当成了请求处理函数(handler),但你传入的是一个配置对象,不是函数,所以才会抛出TypeError: handler is not a function。

functions.https.onRequest()的第一个参数如果是对象,它接受的是HTTP请求级别的配置(比如跨域规则cors),而非实例数量这类运行时配置。运行时配置必须通过runWith()方法来设置。

内容的提问来源于stack exchange,提问作者ChopperOnDick

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 07:44:55