So I am now working a while with firebase, I have read some other topics, this does mean you must upgrade to a paid plan. However, locally I use http and it works fine. and on the server it does not work and throws: Error: getaddrinfo EAI_AGAIN site.com:443
I am not making an external request, the only thing I could think of is that it is external to Cloud functions and to Firebase hosting? Does that count as external? I am only calling/requesting pages on the Hosting side of Firebase. No external pages whatsoever.
What causes this error on the server, and what would be the recommended fix?
This codesample is from the Node.js of the cloud function:main.
var client = http;
client = (req.secure) ? https:client;
// console.log(client)
// const http = new XMLHttpRequest();
function httpRequest(params, postData) {
return new Promise(function(resolve, reject) {
console.log('params' + params)
var req = client.request(params, function(res) {
// reject on bad status
if (res.statusCode < 200 || res.statusCode >= 300) {
return reject(new Error('statusCode=' + res.statusCode));
}
// cumulate data
var body = [];
res.on('data', function(chunk) {
body.push(chunk);
});
// resolve on end
res.on('end', function() {
try {
body = Buffer.concat(body).toString();
} catch(e) {
reject(e);
}
resolve(body);
});
});
// reject on request error
req.on('error', function(err) {
// This is not a "Second reject", just a different sort of failure
reject(err);
});
if (postData) {
req.write(postData);
}
// IMPORTANT
req.end();
});
}