【问题标题】:Setting up Environment Variables for Azure ABP.IO React Mobile App为 Azure ABP.IO React 移动应用设置环境变量
【发布时间】:2021-04-26 12:50:51
【问题描述】:

我已创建 abp.io 项目并将其部署到 Azure。我已经成功创建了 DB 和 Web 应用。

现在我正在探索 React 移动前端。我正在尝试将 React 应用程序指向 localhost 或 Azure 服务器。

我已根据文档 (https://docs.abp.io/en/abp/latest/Getting-Started-React-Native) 将环境变量 'apiUrl' 和 'issuer' 设置为我的 IP 和我的 azure 网站,并得到如下所示的相同错误。

本地主机错误:

Network Error

The above error occurred in task fetchAppConfig
    created by takeLatest(app/fetchAppConfigAsync, fetchAppConfig)
    created by _callee
    created by rootSaga
Tasks cancelled due to error:
takeLatest(app/fetchAppConfigAsync, fetchAppConfig)
takeLatest(app/setLanguageAsync, setLanguage)
takeLatest(app/logoutAsync, logout)

Azure 错误:

Request failed with status code 500
- node_modules\axios\lib\core\createError.js:15:17 in createError
- node_modules\axios\lib\core\settle.js:16:9 in settle
- node_modules\axios\lib\adapters\xhr.js:53:6 in handleLoad
- node_modules\event-target-shim\dist\event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent
- node_modules\react-native\Libraries\Network\XMLHttpRequest.js:592:4 in setReadyState
- node_modules\react-native\Libraries\Network\XMLHttpRequest.js:395:6 in __didCompleteResponse   
- node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:189:10 in emit
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:416:4 in __callFunction
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:109:6 in __guard$argument_0  
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
* [native code]:null in callFunctionReturnFlushedQueue

The above error occurred in task fetchAppConfig
    created by takeLatest(app/fetchAppConfigAsync, fetchAppConfig)
    created by _callee
    created by rootSaga
Tasks cancelled due to error:
takeLatest(app/fetchAppConfigAsync, fetchAppConfig)
takeLatest(app/setLanguageAsync, setLanguage)
takeLatest(app/logoutAsync, logout)

Animated: `useNativeDriver` was not specified. This is a required option and must be explicitly set to `true` or `false`
.
.
.
* [native code]:null in callFunctionReturnFlushedQueue

【问题讨论】:

  • 我在 abp 支持上发现了一个类似的问题,但没有解决方案。 support.abp.io/QA/Questions/682/…
  • > React Native 应用程序不信任自动生成的 .NET HTTPS 证书。您应该在开发过程中使用 HTTP。在 Android 模拟器或物理手机上运行的 React Native 应用程序无法连接到 localhost 上的后端。请确保在 本地 IP 地址HTTP 上运行后端。然后,您应该相应地更新 Environment.js 中的 URL。如果您在应用我上面提到的配置后仍然看到错误,请分享后端错误日志。

标签: reactjs azure abp


【解决方案1】:

我遇到了同样的问题,我做了以下事情:

  1. 使用 HTTP,而不是 HTTPS [我认为这可能会解决您的 azure 问题]
  2. 使用 Conveyor 获取本地 Web 应用程序的 URL,而不是使用 localhost,因为未为移动设备定义 localhost

【讨论】:

    猜你喜欢
    • 2022-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-08
    • 2014-08-02
    • 2016-01-12
    • 2019-12-14
    • 2021-02-18
    相关资源
    最近更新 更多