RequestError: self-signed certificate in certificate chain (Not an issue with axios ) #2413
-
|
We are trying to migrate from Axios. For development environment, we used to set NODE_TLS_REJECT_UNAUTHORIZED='0' for self signed certificates. But this is not working for GOT. As a workaround on local system, I can use below. But I need some solution which does not require additional conditions in code for production. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
The type cast shouldn't be necessary - the await got.get(`${myendpoint}`, {
https: {
rejectUnauthorized: false
},
responseType: 'json'
})For handling dev vs production, you could set this option conditionally based on an enviroment variable like |
Beta Was this translation helpful? Give feedback.
The type cast shouldn't be necessary - the
https.rejectUnauthorizedoption is fully supported in Got's types. You can just use:For handling dev vs production, you could set this option conditionally based on an enviroment variable like
NODE_ENV, so you don't have to worry about it accidently being set in production.