Getting error net::ERR_NAME_NOT_RESOLVED while axios get/post request in my react project

11/28/2021

I am getting error

net::ERR_NAME_NOT_RESOLVED

in browser when my react app hit GET/POST request using axios. Do I need to do any additional things with axios request?

Url is able to access within pods (Kubernetes) but while accessing outside through app it is giving error

-- Laxmikant W.
axios
javascript
kubernetes
reactjs

1 Answer

12/13/2021

I would like to share the solution here,

If the APIs are not exposed to outside world and only want to access through web app simple set the base url with proxy in package.json like as below

"proxy":"https://yourbackendapi";

And deploy the application in the same environment where backend is deployed.

it will also resolved CORS related issue if any.

-- Lucky
Source: StackOverflow