How do I use a specific TLS version with `node-fetch` like TLS v1.2?

499 Views Asked by At

I'm getting a 403 FORBIDDEN error and need to set the TLS version to TLS v1.2 with fetch calls using the node-fetch library. How do I do that?

1

There are 1 best solutions below

0
Dev01 On BEST ANSWER

I figured it out:

You can use the tls library to do it.

const tls = require('tls');

tls.DEFAULT_MIN_VERSION = 'TLSv1.2';

const response = await fetch(...);
...