Node.js request CERT_HAS_EXPIRED
express, javascript, node.js, request
Solution
Add this at the top of your file:
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
DANGEROUS This disables HTTPS / SSL / TLS checking across your entire node.js environment. Please see the solution using an https agent below.
Problem
I'm using Mikeal's request (https://github.com/mikeal/request) to make an https request to a server. However, I keep getting an authorization error of CERT_HAS_EXPIRED. ``` request({ url: 'https://www.domain.com/api/endpoint', strictSSL: false }, function(error, response, body) { if(!error && response.statusCode == 200) { res.json(JSON.parse(body)); } else { res.json(response.statusCode, {'error': 'error'}) } }); ``` I've tried setting strictSSL to true and false, both output same error of CERT_HAS_EXPIRED. What is causing this issue and is there any way to fix it in nodejs?