Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

different default HOST in development mode from webpack-dev-server (0.0.0.0 vs localhost) #3984

Open
benatkin opened this issue Feb 6, 2018 · 3 comments

Comments

@benatkin
Copy link

benatkin commented Feb 6, 2018

The default host in the start script is 0.0.0.0. This differs from the default of webpack-dev-server which is to bind to localhost.

I found this out by reading the output of npm run dev:

You can now view app in the browser.

  Local:            http://localhost:3001/
  On Your Network:  http://192.168.43.210:3001/

Note that the development build is not optimized.
To create a production build, use yarn build.

I hadn't noticed it much before, but I happened to be in a coffee shop working on an API client, so I found it a bit concerning that it was being exposed to the outside. The use case given is for Tools like cloud9. I suggest having them alter their package.json to "start": "HOST=0.0.0.0 react-scripts start" or something instead of having the unusual use case made the default.

If nothing else, if the default can be changed, the message shown when running npm run dev can be simplified. If you have the typical use case of using it for dev only on your machine it's unnecessary, and if you're using ngrok it's a bit redundant.

@Timer
Copy link
Contributor

Timer commented Feb 6, 2018

I believe we'll keep this default.

We make it pretty apparent by saying it's on the network:

On Your Network: http://192.168.43.210:3001/

@benatkin
Copy link
Author

benatkin commented Feb 6, 2018

There are other projects that carefully set it to localhost/127.0.0.1 in development mode: sinatra/sinatra#634 One difference is that create-react-app is frontend, except when it has a proxy (which I've done before).

@felquis
Copy link

felquis commented Mar 19, 2020

Hey Guys, not sure if it is related but I'll follow up this thread maybe it can be closed already right?

Recently I switched my workflow from a Macos to Windows 10 pro, I was used to test my project on multiple devices using the same wi-fi network and my local IP lets say 192.168.15.12:3001

O Windows it doenst seem to work out of the box, not sure if I'm missing some firewall config... do you have it documented somewhre?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants