Closed Smilehwj closed 6 years ago
I have tried using 'Authorization': 'Basic YXBpVXNlcjp1M0tUcWJuSXhLZTA5a2VMOUhGaStMRFRvUUc1b3BzWURjNGQrYVg2' to get data. Still failed, same error.
@Smilehwj
In node.js cannot use self signed certificate by default. https host should have valid cert.
Or disable certificate validation.
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
https://nodejs.org/api/cli.html#cli_node_tls_reject_unauthorized_value
In jest. https://jestjs.io/docs/en/configuration#testenvironment-string
custom_env.js
const JSDOMEnvironment = require('jest-environment-jsdom');
class CustomEnvironment extends JSDOMEnvironment {
async setup() {
await super.setup();
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
}
}
module.exports = CustomEnvironment;
$ npm test -- --env=path/to/custom_env.js
@Smilehwj
In node.js cannot use self signed certificate by default. https host should have valid cert.
Or disable certificate validation.
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
https://nodejs.org/api/cli.html#cli_node_tls_reject_unauthorized_valueIn jest. https://jestjs.io/docs/en/configuration#testenvironment-string
custom_env.js
const JSDOMEnvironment = require('jest-environment-jsdom'); class CustomEnvironment extends JSDOMEnvironment { async setup() { await super.setup(); process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; } } module.exports = CustomEnvironment;
$ npm test -- --env=path/to/custom_env.js
That works for me. Thanks for your help.
}
FetchError: request to https://....... failed, reason: self signed certificate