I'm trying to set up a function that uses Express and makes HTTP requests, but I always get an ENOTFOUND error, no matter the request I make.
I already tried making the requests using 4 different libraries (https, request, request-promise, requestify), but all give the same error.
I followed this examples to set up the system: minimal-webhook + authorized-https-endpoint.
My basic test function, that also throws the error:
"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);
Log of GET request to https://us-central1-project-abc.cloudfunctions.net/test/
using Postman, for example:
Crashed with error Error: getaddrinfo ENOTFOUND www.google.com www.google.com:443
via Sergio Carneiro
No comments:
Post a Comment