how do i remove the ssl certificate requirement from local axios get request in react

Viewed 31

i have recently started testing a local basic API request.

The postrman request says that it is unable to verify the SSL certificate. But it works when I stop it from trying to verify it.

When I run the request in a useEffect in react:

   Axios.get("https://localhost:7075/api/Contacts")

then it pops up with 200 ok, but CORS error, and so no information is shown.

What method is there to replicate the postman situation in react? Or is this the wrong direction?

if I try to access : https://localhost:7075/api/Contacts it shows the information in JSON as normal.

1 Answers

seems like the problem here is cors not ssl. postman is local app so it does not apply 'same-origin' policies on your requests. But axios + reactjs is on browser and browser applies same-origin policies to javascript code so that is that.

Therefore, try setting cors on your api server to allow your react app access. for example, setting cors for expressjs server.

Related