android中通过https返回网络错误的本机POST请求 [英] React-native POST request in android over https return network error

查看:25
本文介绍了android中通过https返回网络错误的本机POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在带有 axios 的 react-native 下通过 https POST 请求创建用户帐户,但在 android 上总是失败并显示网络错误".

Tried to create user account through https POST request under react-native with axios, while it always failed on android with a 'network error'.

axios('https://'+DEST_URI, {
 method: 'post',
 data: account,
 headers: {
   'Accept': 'application/json',
 }
 then(...)

相同的 https POST 请求在 iOS 上运行良好.

The same https POST request works fine on iOS.

改为http,同样的POST请求也适用于android.

Changed to http, the same POST request works on android as well.

还在android上尝试通过https GET请求,它可以按预期从后端服务器检索数据.

Also tried GET request through https on android, it could retrieve data from the backend server as expected.

有什么想法吗?

链接的图像是控制台日志的输出,控制台日志输出

Linked image is the output from console log, output from console log

推荐答案

相关问题 在 react-native 存储库升级到 OkHttp3.

从您的代理停用 http2,这是导致问题的原因.您可以尝试升级到他们在更改日志中提到的 react-native v0.27,他们解决了这个问题,但对我来说没有用.

Deactivate http2 from your proxy that is what causing the problem. You can try to upgrade to react-native v0.27 they mention in the change log that they fixed this problem but for me didn't work.

我必须在 ngnix 中禁用 http2 功能才能使其工作.

I had to disable the http2 feature in ngnix to make it work.

禁用 http2 真的很简单,只需在您的 ngnix 配置文件中更改这一行:

disabling http2 really is this simple, just change this line in your ngnix config file from:

听 443 ssl http2;

听 443 ssl;

然后重新加载您的配置:

then reload your config:

服务nginx重载

可以在此处

这篇关于android中通过https返回网络错误的本机POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆