'Heroku expose localhost expo app to the web
This might be a bit of a strange one, but essentially what I am trying to do is get a very basic testing environment for an early phase react native app using expo. I have been able to set up deployment for Android, however there are a lot of hurdles when it comes to IOS. So what I would like to do in the interim is use Heroku to expose the app which is started by expo start to the web. Where anyone can simply scan the qr code and access a testing version of the app painlessly.
At this stage, performance is not an issue and is only going to be viewed in a small team, so it seems that exactly what is given to me by expo start is perfect. I essentially want exactly what I would get by exposing it via ngrok except hosted on heroku.
Any help would be greatly appreciated.
EDIT: when attempting to use expo start as my web process, I get the following error when accessing it.
2022-03-21T07:07:01.116148+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=my-app.herokuapp.com request_id=a2ecgaa6-c314-4bec-c04c-42f5fe78333a fwd="102.65." dyno= connect= service= status=503 bytes= protocol=https
When specifying port 8080 or using the $PORT env var in my Procfile I receive the following error
2022-03-21T09:44:33.178619+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2022-03-21T09:44:33.220572+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-03-21T09:44:33.250176+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2022-03-21T09:44:33.377609+00:00 heroku[web.1]: Process exited with status 22
2022-03-21T09:44:33.440277+00:00 heroku[web.1]: State changed from starting to crashed
My ProcFile looks as follows:
web: npm install -g expo-cli && expo start --port $PORT
Solution 1:[1]
As the error message states, your application must bind to the web port within 60 seconds of launch. Installing packages as part of your web process definition can easily exhaust that time limit.
I suggest you
make sure to include
expo-sliin yourdevDependencies,tell Heroku not to prune development dependencies by setting
NPM_CONFIG_PRODUCTIONand / orYARN_PRODUCTIONtofalse,modify your
Procfile:web: expo start --port $PORTcommit, and redeploy.
In general, your web process should only tell Heroku the command that needs to run for your server to start. Packing other tasks into it is a code smell.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Chris |
