entity
entity

Reputation: 45

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.

Upvotes: 4

Views: 10694

Answers (2)

xana
xana

Reputation: 21

For someone who comes from 2023, the env EXPO_MANIFEST_PROXY_URL and --no-interactive have been removed. Now you can,

export CI=1
export EXPO_PACKAGER_PROXY_URL="https://metro.example.com"
expo start --no-dev --minify --offline --port 8081

and then point the metro.example.com to localhost:8081 for example and enter exps://metro.example.com in the Expo Go app to access your app.

Upvotes: 1

fson
fson

Reputation: 860

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.

Upvotes: 11

Related Questions