我可以从我在firebase动态托管上托管的快递应用程序连接到mongodb吗?

时间:2018-04-26 10:52:40

标签: mongodb express google-cloud-functions firebase-hosting

我正在尝试从我在firebase动态托管上托管的快速应用程序连接到mongodb。我只是创建了一个端点来保存mongodb上的数据。可以从localhost调用此端点(工作正常)但无法在firebase部署上加载页面(错误:无法处理请求)

const chris = new User({
    name: 'john',
    username: `test`,
    password: `${Date.now()}` 
  });

app.get('/user', (request, response) => {
      chris.save( (err) => {
        if(err) {
            response.send(`error occured`);
        }
        response.send(`${Date.now()}`);
    });
});

1 个答案:

答案 0 :(得分:1)

问题是在免费计划中使用网络呼叫(第三方服务呼叫)存在限制。 ** Cloud Functions for Firebase - Billing account not configured ** d

中的答案

限制是关于出站访问 - 例如您的功能可以从一般互联网请求资源。使用函数响应webhook或访问Google内部服务(例如实时数据库)绝对没问题。

如果您想呼叫第三方网络服务(例如),则需要启用结算功能。

对于其他配额,请查看:https://firebase.google.com/pricing/ - 正如您所看到的,调用次数(写入时为125,000)和CPU和内存(40k cpu-seconds和40k GB)有限制-seconds)在免费套餐中。