diff --git a/templates/node/lib/client.js.twig b/templates/node/lib/client.js.twig index b2538e8e8..c3b8130e5 100644 --- a/templates/node/lib/client.js.twig +++ b/templates/node/lib/client.js.twig @@ -1,5 +1,6 @@ const os = require('os'); const URL = require('url').URL; +const https = require("https"); const axios = require('axios'); const FormData = require('form-data'); const {{spec.title | caseUcfirst}}Exception = require('./exception.js'); @@ -81,11 +82,6 @@ class Client { } async call(method, path = '', headers = {}, params = {}, responseType = 'json') { - if(this.selfSigned) { // Allow self signed requests - process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0; - } - - headers = Object.assign({}, this.headers, headers); let contentType = headers['content-type'].toLowerCase(); @@ -125,6 +121,10 @@ class Client { json: (contentType.startsWith('application/json')), responseType: responseType }; + if (this.selfSigned) { + // Allow self signed requests + options.httpsAgent = new https.Agent({ rejectUnauthorized: false }); + } try { let response = await axios(options); return response.data;