Я пытаюсь настроить среду выполнения quokka.js
для отладки react-hook
.
Моя конфигурация quokka в package.json
:
"quokka": {
"babel": true,
"plugins": [
"./handle_tls_reject_unauthorized", // --> This is where I am struggling
"jsdom-quokka-plugin",
"./quokka_mutation_shim". // --> Setting up MutationObserver (this is fine.)
],
"env": {
"params": {
"env": "NODE_ENV=development"
}
}
},
Я установил NODE_TLS_REJECT_UNAUTHORIZED=0
in handle_tls_reject_unauthorized
.
module.exports = {
before: config => {
/**
* handle_tls_reject_unauthorized.js
* */
require("./config/env");
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = '0';
}
}
И это код извлечения, запускаемый внутри реакционного хука, который я также добавил strictSSL:false
, rejectUnauthorized:false
options.
let opt = {params,
headers:{},
// ca:fs.readFileSync("./fullchain.pem"),
strictSSL: false,
rejectUnauthorized: false,
};
if(auth) {
opt.headers.Authorization = "Bearer "+localStorage.getItem("token");
}
console.log(process.env["NODE_TLS_REJECT_UNAUTHORIZED"]); // = 0
let resp = await axios.get(`${publicUrl}/api/${route}`,opt)
.then(resp =>{
console.log(resp);
return resp.data || resp;
}
)
.catch(err => {
console.log("error");
console.error(err.response)
return err.response.data || err.response;
});
return resp;
но все равно получаю DEPTH_ZERO_SELF_SIGNED_CERT
ошибку.
Это то, что я получаю от JS консоли Quokka.
Error: Error: SSL Error: DEPTH_ZERO_SELF_SIGNED_CERT
at Object.dispatchError (..../node_modules/jsdom-quokka-plugin/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:60:19)
at EventEmitter.client.on.err (..../node_modules/jsdom-quokka-plugin/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:674:20)
at EventEmitter.emit (events.js:203:15)
at Request.preflightClient.on.err (..../node_modules/jsdom-quokka-plugin/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:399:47)
at Request.emit (events.js:198:13)
at Request.onRequestResponse (..../node_modules/request/request.js:952:10)
at ClientRequest.emit (events.js:198:13)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
at TLSSocket.socketOnData (_http_client.js:442:20)
at TLSSocket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at TLSSocket.Readable.push (_stream_readable.js:224:10)
at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17) undefined
undefined
Как мне решить эту проблему?