简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM