Android "failed to fetch" after upgrading from v3 to v5 + Capacitor

Except for what I hope is one final hurdle I’ve been able to upgrade our app from Ionic v3 to Ionic v5 and Capacitor (still using some Cordova plugins as well). A new installation of the app runs fine for web, iOS and Android. Updates to existing installations work fine on web and iOS. However, on Android when updating an existing installation I’m getting a “failed to fetch” error when trying to save a file to local storage. It is also failing to read from the existing PouchDb database. I think that the errors are related - and are something to do with CORS and/or the scheme and host settings. On Ionic V3 I was still using the older Ionic WebView 2.x plugin, so my origin’s were http://localhost:8080 on both iOS and Android. When moving to Capacitor it was important from a user experience point of view, not to lose the existing storage. So in capacitor.config.json I set the following values:

"hostname: “localhost”
"iosScheme: “http”
“androidScheme”: “http”

On iOS this has had the desired affect and I can upgrade an existing installation without losing access to the database and files in storage. However on Android this does not seem to be working. I’ve tried many different configurations to try to get this to work on Android without any success.

1 Like