【问题标题】:firebase functions and external APIfirebase 函数和外部 API
【发布时间】:2018-07-01 12:50:47
【问题描述】:
const functions = require('firebase-functions');
exports.apiResponse = functions.https.onRequest((request, response) => {
const url = "https://test-proj-heroku.herokuapp.com/api/plans"
const https = require('https');
  var req = https.get(url, (resp) => {
    let data = '';
    resp.on('data', (chunk) => { data += chunk; });
    resp.on('end', () => {
        var result = JSON.parse(data);
        response.send({ fulfillmentText: "Firebase ???? API Is Running..." });
      });
    }).on("error", (err) => { console.log("Error: " + err.message); });
});

为什么这个云功能没有响应?在此 URL 上部署 = https://us-central1-ayyanalee-e891b.cloudfunctions.net/apiResponse.

【问题讨论】:

  • 您的云功能日志中有错误吗?您是否使用付费 Firebase 计划? (如果您未使用付费计划,则无法查询非 Google 服务)
  • 这是我的云功能日志:screenshots.firefox.com/9qOFCXf36w8lkprL/…

标签: javascript firebase google-cloud-functions dialogflow-es


【解决方案1】:

您正在尝试向您的 Heroku 服务器(非 Google 产品)发出请求,并且您似乎在 Firebase 的免费层上。正如the pricing page 所指出的,在 Cloud Functions 部分下,免费层仅允许对其他 Google 服务(例如如 Gmail、Google Drive 等...)

如果您想向 Heroku 服务器发出请求,则需要升级到付费 Firebase 层。

【讨论】:

  • 这是否意味着这项服务每次通话都要收费?
  • 不一定。这取决于您使用该服务的程度。 Google Firebase 确定了一些限制。
  • 尽管仍然是 google.com,但 Google Cloud Functions 中也不允许使用 Google reCAPTCHA v3。 See my post here.
猜你喜欢
  • 2019-05-26
  • 2020-12-27
  • 2016-10-08
  • 2020-09-12
  • 1970-01-01
  • 2020-09-06
  • 2017-12-11
  • 2021-03-15
  • 2021-12-04
相关资源
最近更新 更多