Caddy has a neat feature where all routes automatically come with HTTPS enabled. Caddy achieves this by self-signing its own certificate via a certificate authority that is (or can be) added to the system CA list.
However, Node.js comes bundled with its own certificate authority list, so even if Caddy's CA is added to the system, Node won't allow it.
Here's how to allow calls to local https services served by Caddy:
- If needed, run
caddy trust
as root to install the Root CA. - Run node with the environment variable
NODE_EXTRA_CA_CERTS
and point it to the local CA file.- Not sure what that is? Maybe you're on Debian or a derivative (e.g. Ubuntu, Pop!_OS, etc.):
NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt
- Not sure what that is? Maybe you're on Debian or a derivative (e.g. Ubuntu, Pop!_OS, etc.):
That's it.