Connecting to a locally Running app with hotwire native
title: Connecting to a locally-running app with Hotwire Native category: TIL –
I’ve just started a new Hotwire Native application. The Getting Started docs for Android use a deployed domain name, so while the demo app worked just fine, I had a bit of trouble figuring out how to connect to my locally-running web app from an Android emulator. In my case, it was a Rails app, but any other web framework would also have this problem.
There were two useful things I found:
- Android emulators make your computer available at
10.0.2.2
. This means that if you run your web app on port3000
, you can connect in a browser athttp://10.0.2.2:3000
. Neat! - If you are connecting to insecure origins, you need to flag this in your
AndroidManifest.xml
- specifically, you need to addandroid:usesCleartextTraffic="true"
to the<application>
tag.
With this configuration in place, I was able to set up Hotwire Native to connect in debug builds to my locally-running web applicaiton, and I was off!