Skip to content

Commit 8e71ca4

Browse files
Merge pull request #722 from appwrite/fix-6832-node-self-signed
2 parents 0ff8df5 + a644530 commit 8e71ca4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

templates/node/lib/client.js.twig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const os = require('os');
22
const URL = require('url').URL;
3+
const https = require("https");
34
const axios = require('axios');
45
const FormData = require('form-data');
56
const {{spec.title | caseUcfirst}}Exception = require('./exception.js');
@@ -81,11 +82,6 @@ class Client {
8182
}
8283

8384
async call(method, path = '', headers = {}, params = {}, responseType = 'json') {
84-
if(this.selfSigned) { // Allow self signed requests
85-
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
86-
}
87-
88-
8985
headers = Object.assign({}, this.headers, headers);
9086

9187
let contentType = headers['content-type'].toLowerCase();
@@ -125,6 +121,10 @@ class Client {
125121
json: (contentType.startsWith('application/json')),
126122
responseType: responseType
127123
};
124+
if (this.selfSigned) {
125+
// Allow self signed requests
126+
options.httpsAgent = new https.Agent({ rejectUnauthorized: false });
127+
}
128128
try {
129129
let response = await axios(options);
130130
return response.data;

0 commit comments

Comments
 (0)