1

I have one question is when I am hitting a proxy server using axios, I am getting below error, while using npm "request" module it works fine for me.

If anyone can please share thought on this.

Thanks in advance.

Error: getaddrinfo ENOTFOUND http://digitalproxy.gslbext.ngco.com http://digitalproxy.gslbext.ngco.com:80
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
code: 'ENOTFOUND',
  errno: 'ENOTFOUND',
  syscall: 'getaddrinfo',
Loint
  • 3,560
  • 7
  • 26
  • 46
Abhishek Jain
  • 285
  • 1
  • 3
  • 12

1 Answers1

0

If you are using axios proxy configuration using Node.js URL you have to use hostname instead of href. As I have to connect to different instances with different token settings I make use of axios.create()

const axiosInstance = axios.create()
const url = new URL(env.http_proxy)

  const proxyConfig: AxiosProxyConfig = {
    host: url.hostname,
    port: parseInt(url.port)
    }

  axiosInstance.defaults.proxy = proxyConfig
 return axiosInstance
Matthis Kohli
  • 1,877
  • 1
  • 21
  • 23