Remove CORS issue in reactjs

Pramodkumar
Jun 2, 2023

CORS is implemented on the server-side; it cannot be reconfigured on the client-side. The CORS behavior, commonly termed as CORS error, is a mechanism to restrict users from accessing shared resources.

This is not an error but a security measure to secure users or the website which you are accessing from a potential security breach.

This breach may occur due to incomplete or improper HTTP headers on the client-side implementation (eg. missing authorization data such as API key).

Avoid CORS Errors

In package.json add the origin for which api you want to call e.g. origin is https://joke-api-strict-cors-appspot.com. Add proxy as shown below

That’s it now fetch api using the end points as shown below

--

--