Node built in fetch dont reject unauthorized - How to handle self-signed certificates? or Why does no

20 Replies, 1682 Views

Ugh, this is why I switched to `undici` for fetch stuff. The node built in fetch dont reject unauthorized certs, and it’s way too easy to miss.

If you’re stuck with native fetch, here’s the workaround:

```javascript
const agent = new https.Agent({ rejectUnauthorized: true });
await fetch(url, { agent });
```

Also, `ssl-checker` (npm package) can help verify certs if you’re unsure.

Messages In This Thread



Users browsing this thread: 1 Guest(s)