-1

I have my node.js server running on a vm along with a proxy on it. Now i am using node-geocoder to get lat lng from node-geocoder like this

const NodeGeocoder = require('node-geocoder');
var geocoder = NodeGeocoder(constants.config.geocoderOptions);


const geoCodeAddress = await geocoder.geocode(address.location);

now it's throwing an error due to proxy like this

 'request to https://maps.googleapis.com/maps/api/geocode/json?sensor=false&key=my-key&address=Korangi%20Creek failed, reason: getaddrinfo ENOTFOUND maps.googleapis.com maps.googleapis.com:443'

So how can i pass my proxy settings in node-geocoder ?

Fahad Subzwari
  • 2,109
  • 3
  • 24
  • 52

1 Answers1

0

In your options for NodeGeocoder use:

httpAdapter: "request"

This is instead of the http or https options listed in the docs.

Reference: https://github.com/nchaulet/node-geocoder/issues/190

This answer assumes you already have your proxy variables set in your standard setup (so doing curl example.com from terminal returns expected output). If you don't have proxy env variables set you will need to configure that first.