Viewing Create-React-App projects on other devices when running "npm-start"


(Ben Carp) #1

I’m trying to view a CreateReactApp project from a different device. I tried setting the host to 0.0.0.0 by setting the “start” script to: "start": "cross-env HOST=0.0.0.0 react-scripts start".
Though the console did log

Attempting to bind to HOST environment variable: 0.0.0.0
If this was unintentional, check that you haven't mistakenly set it in your shell.
Learn more here: http://bit.ly/2mwWSwH.

I could not access this project from another device on the same network using the computer’s IP.

At the same time I managed to access other projects (from a “tomcat” local server) on the same computer from the same device using the computers IP. Any idea why this might be happening?
My environment: Windows10. I tried it on both ‘PowerShell’, and ‘Bash on Ubuntu on Windows (WSL)’, on more than one Create-React-App project.


(Jakob Lind) #2

I suggest you check out ngrok. It creates a webserver automagically that you can access from any device on the internet. It’s a oneliner:

./ngrok http 3000

That command makes whatever you are running on port 3000 and make it accessible on the internet on a URL that looks something like http://5ca13361.ngrok.io

It’s a really useful application!