Skip to content

Instantly share code, notes, and snippets.

@antoinerousseau
Last active July 15, 2020 21:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoinerousseau/ddafa517cf6cb35331291cc966d84095 to your computer and use it in GitHub Desktop.
Save antoinerousseau/ddafa517cf6cb35331291cc966d84095 to your computer and use it in GitHub Desktop.
List of working and non working fetch requests in RN Android

List of working and non working fetch requests in RN Android

  • React Native version: 0.62.2
  • Affected platform: Android (iOS is working fine)
  • Affected stages: debug & release
  • Affected JS engines: jsc, v8 & Hermes
  • Used phones: Redmi Note
  • Tried to comment out initializeFlipper without success
  • Tried to set FLIPPER_VERSION=0.39.0 without success
  • The problem also happens in Postman on macOS with the "SSL certificate verification" option enabled, although the failing URLs don't show any SSL warning in Chrome browser

Related issues:

Test code

It's a simple GET request using the built-in fetch API.

fetch(URL)
  .then(() => {
    Alert.alert("OK")
  })
  .catch((err) => {
    Alert.alert(err.message)
  })

Working URLs

These URLs work:

$ curl -I https://jsonplaceholder.typicode.com/todos/1
HTTP/1.1 200 OK
Date: Fri, 24 Apr 2020 12:27:19 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 83
Connection: keep-alive
Set-Cookie: __cfduid=d430315d167b8ad791bd61231eadb16e51587731238; expires=Sun, 24-May-20 12:27:18 GMT; path=/; domain=.typicode.com; HttpOnly; SameSite=Lax
X-Powered-By: Express
Vary: Origin, Accept-Encoding
Access-Control-Allow-Credentials: true
Cache-Control: max-age=14400
Pragma: no-cache
Expires: -1
X-Content-Type-Options: nosniff
Etag: W/"53-hfEnumeNh6YirfjyjaujcOPPT+s"
Via: 1.1 vegur
CF-Cache-Status: HIT
Age: 3138
Accept-Ranges: bytes
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 588fd153b91e072a-LHR
cf-request-id: 024dc1284e0000072a299ff200000001
$ curl -I https://pokeapi.co/api/v2/pokemon/ditto/
HTTP/1.1 200 OK
Date: Fri, 24 Apr 2020 12:25:30 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Set-Cookie: __cfduid=d3d542aa363aae957d1ea93d35c7c838e1587731130; expires=Sun, 24-May-20 12:25:30 GMT; path=/; domain=.pokeapi.co; HttpOnly; SameSite=Lax; Secure
Access-Control-Allow-Origin: *
Cache-Control: public, max-age=86400, s-maxage=86400
Etag: W/"28b1-tyDig3BYFY0aqy64yb8Ju6MV01U"
Function-Execution-Id: ajnj5ot998v6
X-Cloud-Trace-Context: fc245d7f1ed8aba09a31ae812c1a2370
X-Powered-By: Express
X-Served-By: cache-cdg20756-CDG
X-Cache: HIT
X-Cache-Hits: 1
X-Timer: S1587100383.588585,VS0,VE1
Vary: Accept-Encoding,cookie,need-authorization, x-fh-requested-host, accept-encoding
CF-Cache-Status: HIT
Age: 15007
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 588fceae5822082c-CDG
cf-request-id: 024dbf80fb0000082cfe3eb200000001
$ curl -I http://ip.jsontest.com/
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json
X-Cloud-Trace-Context: 13cc2aeeaefaca64b310e0f19377a283
Content-Length: 25
Date: Fri, 24 Apr 2020 12:29:33 GMT
Server: Google Frontend
$ curl -I http://ip.jsontest.com/?alloworigin=false
HTTP/1.1 200 OK
Content-Type: application/json
X-Cloud-Trace-Context: ca852b68ff3c24a7bf876706ab38db1d
Content-Length: 25
Date: Fri, 24 Apr 2020 12:29:47 GMT
Server: Google Frontend
$ curl -I https://postman-echo.com/get
HTTP/1.1 200 OK
Content-Length: 181
Content-Type: application/json; charset=utf-8
Date: Fri, 24 Apr 2020 12:54:37 GMT
ETag: W/"b5-6d5ifhyrvsuS0ppzbyQT4j74V4U"
Server: nginx
set-cookie: sails.sid=s%3AaXeTw8w-8uRS9mY-GcLIJUB1yiokdwAE.05dYu3YtdThLpaXdB1mAXuYZeh1xQN4VM7sF8pra8rc; Path=/; HttpOnly
Vary: Accept-Encoding
Connection: keep-alive
$ curl -I https://httpbin.org/get
HTTP/1.1 200 OK
Date: Fri, 24 Apr 2020 13:00:48 GMT
Content-Type: application/json
Content-Length: 256
Connection: keep-alive
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true

Failing URLs

These URLs raise a TypeError: Network request failed:

$ curl -I https://www.mocky.io/v2/5185415ba171ea3a00704eed
HTTP/1.1 200 OK
Server: Cowboy
Connection: keep-alive
Date: Fri, 24 Apr 2020 12:26:45 GMT
Content-Type: application/json
Content-Length: 18
Via: 1.1 vegur
$ curl -I https://pixiumdigital.com
HTTP/1.1 200 OK
Date: Mon, 27 Apr 2020 10:02:30 GMT
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/7.1.33
X-Powered-By: PHP/7.1.33
Link: <https://pixiumdigital.com/wp-json/>; rel="https://api.w.org/"
Link: <https://pixiumdigital.com/>; rel=shortlink
Last-Modified: Mon, 27 Apr 2020 09:57:46 GMT
ETag: "121f90e263d3f26a1b490545303d666a"
Set-Cookie: qtrans_front_language=en; expires=Tue, 27-Apr-2021 10:02:30 GMT; Max-Age=31536000; path=/
Set-Cookie: PHPSESSID=v2u861ud3h2q1k2l1p9dec45mg; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Link: <https://pixiumdigital.com/wp-json/>; rel="https://api.w.org/"
Link: <https://pixiumdigital.com/>; rel=shortlink
Referrer-Policy:
Content-Type: text/html; charset=UTF-8

(undisclosed https private drupal graphql api)

fetch("https://some-drupal-api.fr/fr/graphql", {
  headers: {
    Authorization: `Basic ${base64.encode(`user:password`)}`,
  },
})
$ curl --user user:password -I https://some-drupal-api.fr/fr/graphql
HTTP/1.1 200 OK
Server: nginx
Content-Type: application/json
Connection: keep-alive
Vary: Accept-Encoding
Cache-Control: must-revalidate, no-cache, private
Date: Fri, 24 Apr 2020 10:35:22 GMT
X-Drupal-Dynamic-Cache: UNCACHEABLE
X-UA-Compatible: IE=edge
Content-language: fr
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Vary:
X-Generator: Drupal 8 (https://www.drupal.org)
X-Drupal-Cache: HIT
Access-Control-Allow-Origin: https://www.some-drupal-site.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment