Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Host Expo app on external network?

I am writing an app with create-react-native-app (CRNA) for a company. Eventually, it might reach production, but for research reasons I need a working prototype that I can deploy to coworkers phones easily (Android and iOS).

Due to intellectual property, I am not allowed to publish on any external hosted platform (Google Play, App Store, Expo-hosted, etc). I do however have access to an internal server that can communicate outside the company intranet.

Given this, I was wondering if it is possible to run the local Expo server spawned by npm start in such a way that it would accept foreign connections (I.e. via port forwarding, proxy, or a VPN).

Password security would be ideal, but just secrecy would be okay if that's the only option. Ofc that would fall under network security respective of the answer.

like image 421
entity Avatar asked Jan 03 '23 17:01

entity


1 Answers

It is possible to run the development server this way. You might want to use the Expo CLI to start the server because it allows to tweak more options (it anyway starts the same XDL server as CRNA does).

For your internal testing you could start the server with exp start --no-dev --minify --offline --non-interactive.

  • --no-dev and --minify tell the server to serve a minified production bundle instead of dev bundle.
  • --offline allows the server to run without logging in with an Expo account (useful if you're running this on a server)
  • --non-interactive makes the command fail, if it would require input.

You need to have two publicly accessible ports on the server: one for the XDL server and other for Metro bundler. You can set XDL port by creating a .exprc file in the project directory with following contents:

{ "manifestPort": <XDL server port> }

You can set the Metro port by adding this in your app.json file:

{"expo": {"packagerOpts": { "port": <Metro port> }}}

Using a proxy

If you want to run a proxy (such as NGINX) in front of the server to control access to it or to enable HTTPS, you can use these environment variables to tell exp about the publicly accessible URL of your proxy:

export EXPO_MANIFEST_PROXY_URL="https://your-public-url-for-xdl.example.com"
export EXPO_PACKAGER_PROXY_URL="https://your-public-url-for-metro.example.com"

The Expo Client can then open the app from exp://your-public-url-for-xdl.example.com:443.

like image 160
fson Avatar answered Jan 05 '23 16:01

fson