Skip to content

Commit 391e0d6

Browse files
committed
Fix invalid cert errors on 127.0.0.1
Fingers crossed if this does not crash client
1 parent 481691c commit 391e0d6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/dispatchRequest.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const axiosInstance = require('./axiosInstance')
22
const UTILS = require('./utils.js')
33
const CONST = require('./const.js')
44
const ErrorMessage = require('./errorMessage')
5+
const https = require('https');
56

67
/**
78
* base 64 encodes a string using either the btoa implementation if available or the Buffer object.
@@ -25,6 +26,9 @@ function btoaImplementation(str) {
2526
* @param {String} key optional basic auth string to be passed
2627
*/
2728
function DispatchRequest(url, action, payload, local_auth, remote_auth = null) {
29+
const agent = new https.Agent({
30+
rejectUnauthorized: !url.startsWith("https://127.0.0.1")
31+
});
2832
/*
2933
*CORS is only required when trying to fetch data from a browser,
3034
*as browsers by default will block requests to different origins
@@ -33,6 +37,7 @@ function DispatchRequest(url, action, payload, local_auth, remote_auth = null) {
3337
mode: 'cors', // no-cors, cors, *same-origin
3438
redirect: 'follow', // manual, *follow, error
3539
referrer: 'client',
40+
httpsAgent: agent,
3641
// url:url,
3742
// no-referrer, *client
3843
}

0 commit comments

Comments
 (0)