Android device - "Network request failed" when calling fetch() on https URL


#1

Code snippet below works fine on iOS and Fuse local preview, but network request fails on an Android device. The actual message is Network request failed. No response received, just the error gets thrown in the .catch().

If I change my requestUrl to be plain old http instead of https then I at least get a 302 redirect, with a response.ok of false. But http is not an option here, my request has to be https.

fetch(requestUrl)
	.then(function(response) {
		console.log(response.status);
		console.log(response.ok);
		console.log(response);
		return response.text();
	})
	.then(function(responseObject) {
		console.log(responseObject);
	})
	.catch(function(err) {
		console.log( 'Error : ' + err.message );
	});


#2

As found in further debugging, the problem is that Android is somehow more restrictive about what certificates it considers trusted. Apparently, you need to add some intermediate/chain certificate(s) that would link your “Let’s encrypt” certificate to a trusted root certificate authority.


#3

Thanks Uldis! For the time being, I have redirected all https traffic to http with a simple mod_rewrite in my .htaccess file. Will look into creating these intermediate certs.


#4

Do you have the solution ? I have the same issue