I have a curl call that looks like this:
curl \
-v \
-X POST \
-k \
-H 'Content-Type: application/json' \
-d '{
"mydata": "XXXXX"
}' \
"https://localhost:11000/myEndpoint"
It works. I get a 200 response. But when I remove the -k
flag, it fails with this error:
curl: (60) SSL certificate problem: self signed certificate
So I know that the -k
flag is required.
Now I'm trying to convert this curl to Javascript/React. But when I do this in React, it fails:
const response = await fetch(
'https://localhost:11000/myEndpoint',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ mydata: 'XXXXX' })
},
)
Here is the error in the browser console:
POST https://localhost:11000/myEndpoint net::ERR_CERT_AUTHORITY_INVALID
I believe this error is because the Javascript/React is not doing the equivalent of a -k
.
How can I make it mimic the -k
behavior of Curl?