0

I have a function app deployed on Azure.

My requirement is to call another API internal to the organization.

But all the traffic has to be routed through a proxy server setup on prem. How do I tell my NodeJs code, to make the outbound request using a proxy server.

I did set the http and https proxy in node runtime using npm set commands, that seems to have no effect.

I am seeing host not found errors. To both the proxy server and the actual api.

  • Does this answer your question? [How to override node.js http to use a proxy for all outbound requests](https://stackoverflow.com/questions/16442985/how-to-override-node-js-http-to-use-a-proxy-for-all-outbound-requests) – Ecstasy Jul 05 '22 at 04:51
  • [How can I use an http proxy with node.js http.Client?](https://stackoverflow.com/questions/3862813/how-can-i-use-an-http-proxy-with-node-js-http-client) – Ecstasy Jul 05 '22 at 04:51
  • 1
    Does this answer your question? [How can I use an http proxy with node.js http.Client?](https://stackoverflow.com/questions/3862813/how-can-i-use-an-http-proxy-with-node-js-http-client) –  Jul 30 '22 at 14:56

1 Answers1

0

Here is the code to add proxy for Azure functions

var http = require("http");

var options = {
  host: "proxy",
  port: 8080,
  path: "http://www.google.com",
  headers: {
    Host: "www.google.com"
  }
};
http.get(options, function(res) {
  console.log(res);
  res.pipe(process.stdout);
});

For more information you can refer the SO

SaiSakethGuduru
  • 2,218
  • 1
  • 5
  • 15