react-native: fetch fails with [TypeError: Network request failed] on Android with certain url
Reproduced on React-Native 0.21, 0.22.0 , and 0.22.2
fetch('https://api-dev.semios.com/', {
method: 'POST',
}).then((response) => {console.log(response)}).catch((error) => {console.log(error)})
fails with [TypeError: Network request failed] only on Android – this works properly on iOS Reproduced with https://rnplay.org/apps/MUs3SQ
I/ReactNativeJS( 2790): [TypeError: Network request failed]
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 6
- Comments: 16 (5 by maintainers)
Commits related to this issue
- fix: fix false positives for circular object check fixes #6827 — committed to react-one/react-native by satya164 4 years ago
I’m having a similar issue but mine isn’t even related to SSL. I’m just trying to run the example
fetch
from the RN docs calling out to http://facebook.github.io/react-native/movies.json. When I try it out on the simulator its fine. But when I plug in my device and and deploy it to that usingreact-native run-android
it can’t seem to successfully load the data.Any suggestions?
Adding in my case here: Similar situation as OP, https URL failing with
[TypeError: Network request failed]
on Android, successful on iOS, certificate showing as valid in browser.In my case, had SSL setup on nginx with Let’s Encrypt but left out the intermediate certificates, i.e. I was using the
cert.pem
instead offullchain.pem
. This thread has some more info. Once I got the intermediate cert configured correctly, Android/OkHttp accepted it.This blog post might describe what’s happening: http://steveliles.github.io/android_ssl_certificate_not_trusted.html