Skip to content

Commit

Permalink
Prefer localhost as an address (facebook#2154)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer authored and romaindso committed Jul 10, 2017
1 parent 4bfc45a commit 9452e7e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/react-scripts/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ function run(port) {
pathname: '/',
});

let prettyHost;
if (HOST === '0.0.0.0' || HOST === '::') {
prettyHost = 'localhost';
} else {
prettyHost = HOST;
}
const prettyUrl = url.format({
protocol,
hostname: prettyHost,
port,
pathname: '/',
});

// Create a webpack compiler that is configured with custom messages.
const compiler = createWebpackCompiler(
config,
Expand Down Expand Up @@ -100,7 +113,7 @@ function run(port) {
console.log(chalk.cyan('Starting the development server...'));
console.log();

openBrowser(formattedUrl);
openBrowser(prettyUrl);
});
}

Expand Down

0 comments on commit 9452e7e

Please sign in to comment.