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

[INFO] Change host and ip on webpack startup #32

Closed
pihomeserver opened this issue Nov 24, 2017 · 2 comments
Closed

[INFO] Change host and ip on webpack startup #32

pihomeserver opened this issue Nov 24, 2017 · 2 comments

Comments

@pihomeserver
Copy link

pihomeserver commented Nov 24, 2017

For those who want to change default host and ip when starting the server, here is what i did (i'm not expert so please correct if needed).
In webpack.config.js i added :

  • Before module.exports:
const ENV = process.env.ENV = process.env.NODE_ENV = 'development';
const HOST = process.env.HOST || 'localhost';
const PORT = process.env.PORT || 3000;

const METADATA = Object.assign({}, {
    host: HOST,
    port: PORT,
    PUBLIC: process.env.PUBLIC_DEV || HOST + ':' + PORT
});
  • In the devServer section, add :
        port: METADATA.port,
        host: METADATA.host,
        public: METADATA.PUBLIC,

Then you can call the server like this :

HOST='192.168.10.160' npm start
@tvl83
Copy link

tvl83 commented Nov 25, 2017

If you add host: '0.0.0.0' to the devServer object in webpack.config.js it'll bind to any IP address. I use this on a vultr VPS and on a local virtualbox VM and to access it from my desktop computer I bound the IP to 0.0.0.0 and it works like a charm.

@xidedix
Copy link
Member

xidedix commented Jun 21, 2018

With unejected create-react-app you can adjust this by setting environment variables with .env files
See also:

@woothu woothu closed this as completed Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants