is there an easy way to disable SSL validation in Axios. I tried this process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
but it doesn't work.
Here's an example of my code"
const postPosts = () => {
axios
.post("https://xxx.dev.lab", {
Username: "xxx",
Password: "xxx"
})
.then(response => {
console.log(response);
})
.catch(error => {
console.error(error);
});
};
postPosts();
Axios doesn't address that situation so far - you can try:
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
BUT THATS A VERY BAD IDEA since it disables SSL across the whole node server..
or you can configure axios to use a custom agent and set rejectUnauthorized to false for that agent as mentioned here
example:
// At instance level
const instance = axios.create({
httpsAgent: new https.Agent({
rejectUnauthorized: false
})
});
instance.get('https://something.com/foo');
// At request level
const agent = new https.Agent({
rejectUnauthorized: false
});
axios.get('https://something.com/foo', { httpsAgent: agent });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With