Capacitor server.hostname same as web deployment URL on Android

I have a Next.js app that I deploy to web, let’s say to URL https://example.com, and also wrap with Capacitor to release to Android and iOS. To enable the autofill feature on Android, we set server.androidScheme to https, and server.hostname to example.com in capacitor config. The autofill works fine, however I realised that when I statically build my app and run it, the app renders the contents of my web deployment and completely ignoring what is bundled with the app on build time.

Please let me know if any of this is wrong but how I assume a Capacitor app works is that when I run the app, it starts a locally running server that serves the contents of the web app, and renders it on the web view. The URL of this locally running server is made up of what is in Capacitor config files, so in my case, it’s https://example.com which is the same as my web deployment. So when the app tries to fetch the contents of the app from this local server, it fetches them from the web deployment instead, hence the local contents being ignored.

This is currently blocking an Android release because we don’t want our mobile apps to be completely in sync with our web deployments, at least without our control. Has anyone else experienced a similar issue?

It works the other way, it loads the local assets and if you try to connect to a endpoint that is only online it will 404 as it’s not there on the local assets.

Maybe you have set the server.url to https://example.com? that’s the only way of loading the remote assets instead of the local ones.

Hey @julio-ionic, thanks for the reply. We don’t use server.url at all.

So you mean even if the URL’s are the same, the requests always resolve to the locally running server rather than the remote one?

yes, the should never reach the server as they are intercepted by Capacitor

Okay, thank you so much for the info. I got this behaviour when I was running a static prod build on my device through Android Studio and had the Chrome inspector attached to the app. It seems the builds we upload to Google Play internal channel don’t really have this behaviour, so I’ll just assume the interception logic somehow didn’t work for that setup and leave it at that.