React应用程序无法从Azure SQL后端获取数据(无法加载资源:NET :: ERR_CONNECTION_REFUSE)
我在Azure上使用ASP.NET Core 5.0.17 App托管了React Spa,但无法从API获取数据。我还托管了Azure SQL Backend上的SQL数据库,并更改了Web应用程序上的连接字符串以匹配它。为什么React应用程序仍然无法获取数据?
无法加载资源:net :: err_connection_refused: https://freeimage.host/i/h7ii2f
garacyforecastController Api能够从硬座上的数据中获取addodeded array: https://freeimage.host/i/h7i91a
文件: https://freeimage.host/i/h7ioeg https://onboarding2.azurewebsites.2.azurewebsites.net/api/customers
Postman返回API的数据返回数据: https://freeimage.host/i/h7sssdb
I hosted a React SPA with ASP.NET Core 5.0.17 App on Azure but it is unable to fetch data from the API. I've also hosted the SQL database on Azure SQL backend and changed the connection strings on the Web App to match it. Why is the React App still unable to fetch data?
Failed to load resource: net::ERR_CONNECTION_REFUSED:
https://freeimage.host/i/h7iI2f
WeatherForecastcontroller API is able to fetch data from hardcoded array: https://freeimage.host/i/h7i91a
This is my Fetch API source URI saved in .env file: https://freeimage.host/i/h7iOEg
https://onboarding2.azurewebsites.net/api/customers
Postman is returning data from API: https://freeimage.host/i/h7ssDB
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题很明显,应该是
.env
文件在水疗中没有生效。请检查此博客。本文详细描述了如何配置和启用环境变量。
将环境添加到ASP.NET核心的react.js spa
This problem is obvious, it should be that
.env
file does not take effect in SPA.Please check this blogs.This article describes in detail how to configure and enable environment variables.
Adding environments to ASP.NET Core with React.js SPA