I've been developing a React Native app and most of my functionality is now in place. The backend is a REST API written in Kotlin using the Spark microframework on top of a PostgreSQL database. The app was first written using react-native init
before Expo was a thing. I've been using iOS to test the app as I develop it, although the code is pure React Native so porting to Android shouldn't be a massive problem.
When my REST API server was running on localhost:1337 my app experienced no problems whatsoever, however yesterday I deployed to an EC2 instance and secured it using a certificate obtained via letsencrypt (using a Java keystore). Manual queries to the API via the web browser work perfectly (and the certificates are valid) and the queries also work on the Safari browser within the iOS Simulator, but on the simulated React Native app every request now fails since I've pointed them to my new server. The GET requests fail with a warning promise rejection: network request failed and the POST requests fail with a crash and the same error. The requests are given in the form:
var url = "https://example.com/api/posts?lat=" +
lat + "&lon=" + lon;
this.setState({url: url});
const bar = this;
fetch(url)
.then(response => response.json())
.then(data => {
var foo = JSON.stringify(data);
this.setState({ posts: foo});
})
.catch((err) => {
console.log(err)
reject(err)
});
I've done all of the usual React Native generic solutions like wiping and rebuilding my ios/build directory, re-installing all my Node modules and even adding an exception to my domain in info.plist (even allowing insecure requests generally, which I think is a bit of a black mark when applying for App Store approval) to no avail whatsoever. When I get home I intend to probe the connection with Wireshark but as the requests are failing immediately without any delay I expect it'll only confirm my suspicion that the requests don't go up at all and are being denied by iOS for some reason. Most of the questions I've seen in my debugging efforts talk about HTTPS working and HTTP failing, which is easily solvable by setting a variable in the iOS config. I've not come across this, the opposite problem in any recent version of React Native.
Any advice with this issue would be much appreciated, I'm really tearing my hair out here. Thanks in advance.