Run Android with HTTPS scheme

I need to run my app with SSL https:// scheme. Currently when I make a production build and open the app in android studio to run on my physical device, the app is served over “http://localhost”. This prevents me from calling secure APIs and store secure cookies from responses.

I have also tried changing capacitor.config.json as such, with no luck:

	"hostname": "localhost",
	"androidScheme": "https"

Any ideas? This does work locally when running “–ssl” flag, but cannot change it on android builds.

While this may not be an option for your situation, if you have control over the backends, my idea would be “don’t use cookies”. Cookies try to force HTTP into being stateful, while tokens do their job perfectly well even in HTTP’s natural stateless world.

Also perhaps irrelevant to your situation (as you are explicitly mentioning Android in your thread topic), but, according to @jcesarmobile, what you desire is categorically impossible on iOS due to deliberate OS design decisions made by Apple. So if iOS is even a possibility in the future, you definitely want a way to reach your ultimate goal that doesn’t involve changing the internal URL scheme of the app.

1 Like

Should work on Android, but should be inside "server" object.

But doesn’t mean it will use SSL, SSL is about the server communication and in capacitor there is no real server, the assets are local. Not sure if using https as protocol will solve your issues.