Error: self-signed certificate in certificate chain
Node refused the HTTPS connection because a certificate in the chain was signed by a CA it doesn't trust, usually a corporate proxy or an internal company CA.
Published
Why this happens
A corporate proxy or VPN intercepts TLS traffic and re-signs it with its own root certificate
The staging API uses a certificate issued by an internal CA that isn't in Node's bundled CA list
Node doesn't read the operating system's trust store by default, so a CA your browser trusts can still fail in Node
How to fix it
Point Node at the extra CA with `NODE_EXTRA_CA_CERTS=/path/to/company-ca.pem`
Or, on Node 23.8+ (and 22.15+), use `--use-system-ca` so Node trusts the same CAs as the operating system
Avoid `NODE_TLS_REJECT_UNAUTHORIZED=0`. It turns off certificate checks for every request in the process, and it tends to get copied into CI and forgotten
Example
# Trust the company CA for this test run only
NODE_EXTRA_CA_CERTS=./certs/company-root-ca.pem npm run test:api