【问题标题】:Cannot connect to Apollo GraphQL server on Android Release [react native]无法连接到 Android 版本上的 Apollo GraphQL 服务器 [react native]
【发布时间】:2020-02-27 19:36:43
【问题描述】:
    httpURI = 'http://17.25.16.68:4000/graphql' //example
    const httpLink = createHttpLink({ uri: httpURI });
    const client = new ApolloClient({ link:httpLink, cache: new InMemoryCache() });

连接在调试模式下工作,但是当我在发布时运行它时,没有建立连接。

我是否需要在 Android 版本配置中的某处启用传出连接?

【问题讨论】:

标签: android react-native http graphql apollo


【解决方案1】:

这对我有用。显然,android pie 不允许对没有 https 的 URL 进行网络请求。

<application
        ...
        android:usesCleartextTraffic="true"
        ...>
        ...
</application>

【讨论】:

    【解决方案2】:

    此文件允许 android 访问 http 请求。 在 android/app/src/main/AndroidManifest.xml 添加下面的行

    <application 
       .
       .
       .
       android:usesCleartextTraffic="true"
       .
       .
       .
    >
    </application>
    

    【讨论】:

      猜你喜欢
      • 2023-03-22
      • 2018-05-24
      • 1970-01-01
      • 2019-12-09
      • 1970-01-01
      • 2022-11-13
      • 2017-10-11
      • 2016-10-20
      • 2015-02-22
      相关资源
      最近更新 更多