我试图设置一个函数,它使用Express并发出HTTP请求,但我总是得到一个ENOTFOUND错误,无论我提出的请求。Firebase函数ENOTFOUND所有http请求
我已经尝试使用4个不同的库(https,request,request-promise,requestify)来发出请求,但都给出相同的错误。
我按照这个例子来设置系统:minimal-webhook + authorized-https-endpoint。
我的基本测试功能,这也引发错误:
"use strict";
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp(functions.config().firebase);
const express = require("express");
const app = express();
const https = require("https");
app.get("*", (req, res) =>
{
var testReq = https.request({
host: "www.google.com",
path: "/recaptcha/api/siteverify"
},
(res) => {
console.log("Finished with response " + res);
});
testReq.on("error", (e) => {
console.log("Crashed with error " + e);
});
testReq.end();
});
exports.test = functions.https.onRequest(app);
登录GET请求到https://us-central1-project-abc.cloudfunctions.net/test/
使用邮差,例如:
Crashed with error Error: getaddrinfo ENOTFOUND www.google.com www.google.com:443
'出境connections' ......继这个想法,我会说这是我的自由的计划的问题。 Firebase表示它“仅允许向Google拥有的服务发送出站网络请求”。但是我正在向Google服务提出请求,不是吗? –
我遇到了同样的问题。也许需要升级计划 – John