Accessing an HTTPS Service from Node.js

    If you’re looking for a reliable solution to handle HTTP and HTTPS requests in Node.js, the https-proxy-agent is a great option to consider. This agent allows you to route your requests through a proxy server, providing a secure and efficient way to communicate with external APIs or websites. By integrating the https-proxy-agent into your code, you can ensure that your HTTP and HTTPS requests are handled seamlessly.

    We recommend the https-proxy-agent library for carrying out HTTP operations from Node.js with QuotaGuard.


    When you sign up with QuotaGuard, you will be provided with a unique username and password and a connection string that you can use when configuring your proxy service in your application, for example:

    All requests that you make via this proxy will appear to the destination server to originate from one of the two static IPs you will be assigned when you sign up.

    We recommend you store the connection string in an environment variable QUOTAGUARD_URL. If you have signed up via the add-ons platform on Heroku or cloudControl this variable will be automatically set in your production environment.


    QuotaGuard will work with the standard http library, but we recommend using the https-proxy-agent library for ease of use.

    var HttpsProxyAgent = require('https-proxy-agent');
    var request = require('request');
    var proxy = process.env.QUOTAGUARDSTATIC_URL;
    var agent = new HttpsProxyAgent(proxy);
      uri: "",
      method: "POST",
      headers: {
        'content-type': 'application/x-www-form-urlencoded'
      agent: agent,
      timeout: 10000,
      followRedirect: true,
      maxRedirects: 10,
      body: "name=john"
    }, function(error, response, body) {
      console.log("Error" + error);
      console.log("Response: " + response);
      console.log("Body: " + body);

    Other Libraries

    We have examples for other common libraries as well, but if you can’t find what you are looking for just send us a Support ticket and we’ll get one sent to you.

    Ready to Get Started?

    Get in touch or create a free trial account