I have a simple HTTPS request that works well on my local envoiremnt. But on aws lambda it works for some urls only and for other urls it can't be resolved and I'm getting this error:
"Error: getaddrinfo ENOTFOUND myUrl.co.il",
" at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)"
The script is just a simple https request:
const params = {
host: event.url , // event.url is without https! just the DNS
path: "/login",
};
const req = https.request(params, function(res) {
let data = '';
console.log('STATUS: ' + res.statusCode);
res.setEncoding('utf8');
res.on('data', function(chunk) {
data += chunk;
});
res.on('end', function() {
console.log("DONE");
console.log(JSON.parse(data));
});
});
req.end();
};
** When event.url = url1 it work on lambda and my local but when event.url = url2 it work only on my local, on lambda I got the getaddrinfo error.
** If i replace the event.url with the url ip address and add rejectUnauthorized:false" it will work on both urls on both envoiremnt. (ofc i dont like this solution , it just to demonstrate that the issue is with the dns resolver on aws lambda envoiremnt)
I'm not sure what do u mean? both , url1 and url2 are just example to demonstrate that some url can't be resolved.
Yeah I was checking what ever url your not having an issue with wasn’t in your host file