androidreactjshttpsexpofetch

Expo Go HTTPS-Request doesn't work on android but works on every other OS. (HTTP-Requests are working)


When I change my environment variable from https://XXXX.com to http://37.XX.XXX.XXX:XXXX, my Expo Go app on Android works, but the HTTPS request doesn't.

Versions:

try {
  const response = await fetch(
    process.env.EXPO_PUBLIC_API_URL + "/login/create",
    {
      method: "GET",
      headers: {
        "Content-Type": "application/json",
        "User-Agent": "Mozilla/5.0",
      },
    }
  );

  console.log(response);

  if (!response.ok) {
    throw new Error(`Fetch request failed with status ${response.status}`);
  }

  const data = await response.json();

  setError("received");
  console.log("Data received:", data);


  // Working with the response
} catch (error) {
  console.error("Fehler beim Abrufen der Daten:", error);
}

I checked the app.json multiple times:

"android": {
  "adaptiveIcon": {
    "foregroundImage": "./assets/images/icon.png",
    "backgroundColor": "#ffffff"
  },
  "package": "XXX",
  "versionCode": 13,
  "permissions": [
    "INTERNET",
    "ACCESS_NETWORK_STATE"
  ]
},

This bug occurs only on Android, including in the build version of the app.


Solution

  • So it's working now.

    My error was, that there was an underscore (_) in my domain name. WTF Android...