3

This is my first time in stackoverflow and I need some help. Here is the problem:

I need to get an image from postimg.org with http(s).request() and sent it to the client as dataUrl. Let's say that the image address is: "https://s20.postimg.org/lsjlwkdf/how_beautyfull_you_are.jpg"

The reason to get the image with the server and then send it to the client as dataurl from my server is that tainted canvases can not be used in browser.

The problem is that when i make a http(s) request from the server to the "s20.postimg.org/lsjlwkdf/how_beautyfull_you_are.jpg", then GetAddrInfoReqWrap.onlookup throw an error:

Error: getaddrinfo ENOTFOUND s20.postimg.org s20.postimg.org:443
            at errnoException (dns.js:28:10)
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)

When I use my localhost server I do not get this error, but when i run it from cloud droplet server I get the error. I have tried it with any possible ways i could find (native nodejs http(s).request(), fetch-node fetch(), request-node ) and always have the same problem. Finally I understand that the problem is that "getaddrinfo" can not resolve the hostname "s20.postimg.org"

Code:

dns.lookup(host, function (err, address, family) {
    if (err) {
       res.status(404).end();
       console.log("dns.lookup error:", err);
    } else {
       console.log( "address:", address, "family:", family );
       if ( field.value.split("/")[0] == "http:" ) {
           var request = http.request(options, callback );
           request.end();
       } else if ( field.value.split("/")[0] == "https:" ) {
           var request = https.request(options, callback );
           request.end();
       }
    }
});

Is it possible to bypass the getaddrinfo at http(s) request?

Thank you in advance.

Stephanua
  • 31
  • 1
  • 5
  • 1
    did you able to resolve this ?. i am also facing same issue. got sucked found no solution. if you able to solve please share the solution. – Ashish Patel Nov 25 '19 at 06:50

0 Answers0