简体   繁体   English

在我的反应项目中 axios 获取/发布请求时出现错误 net::ERR_NAME_NOT_RESOLVED

[英]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净::ERR_NAME_NOT_RESOLVED

in browser when my react app hit GET/POST request using axios.当我的反应应用程序使用 axios 命中 GET/POST 请求时,在浏览器中。 Do I need to do any additional things with axios request?我需要对 axios 请求做任何其他事情吗?

Url is able to access within pods (Kubernetes) but while accessing outside through app it is giving error Url 能够在 pod (Kubernetes) 内访问,但在通过应用程序访问外部时出现错误

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 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.如果有的话,它还将解决 CORS 相关问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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