0

When sending request to google places photos api I am getting the following error in my firebase logs.

error: { Error: getaddrinfo ENOTFOUND lh4.googleusercontent.com lh4.googleusercontent.com:443
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)

Which would seem it's related to a DNS lookup failure. Here is the code where I send the request. The url I submit is correct and valid, and I have checked this in the logs.

var getPhoto = function(request, response){
    var req = require('request');
    var url = "VALID_URL_HERE";

    req(url, function(error, res, body){
        response.send(body);
    });
}

I have seen some similar answers saying you cannot make requests to external hosts. But I don't think this is my problem, as it is a google api service and I successfully call the google places api in another firebase function.

Any help is much appreciated.

pip36
  • 126
  • 1
  • 8
  • I'm on the free tier. I am able to make a outbound requests to the google places search endpoint though. Only the image endpoint is not working? Is there a reason for that? – pip36 Oct 17 '17 at 10:11
  • Could you edit your question to be more specific about how you're generating the URL for the API request? – Doug Stevenson Oct 17 '17 at 19:12
  • I'm pretty sure it's not the URL that's the problem. I've tried logging it, and opening in browser, and it returns the image. I think it must be firebase free tier disallowing it, and perhaps I got lucky with my other successful request. – pip36 Oct 18 '17 at 07:44
  • I'm gonna guess that whatever you're trying to access at lh4.googleusercontent.com is not considered a "google API". Can you be more specific about what you're trying to do? – Doug Stevenson Oct 20 '17 at 23:07
  • https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=PHOTO_REFERENCE&key=API_KEY This is the URL that's failing the request. With my api key and photo ref substituted. – pip36 Oct 21 '17 at 11:58
  • As i'm writing the comment. I realise you may be right, as the image returned from the api call seems to source from whoever uploaded the image to google maps. So it may be considered an external url as you say. – pip36 Oct 21 '17 at 12:00

0 Answers0