Skip to content

Commit 281e8d2

Browse files
committed
Add support for IPv6 hosts
1 parent 71a27c0 commit 281e8d2

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

packages/react-dev-utils/prepareProxy.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ module.exports = function prepareProxy(proxy) {
7373
// `proxy` lets you specify alternate servers for specific requests.
7474
// It can either be a string or an object conforming to the Webpack dev server proxy configuration
7575
// https://webpack.github.io/docs/webpack-dev-server.html
76-
if (!proxy) return undefined;
76+
if (!proxy) {
77+
return undefined;
78+
}
7779
if (typeof proxy !== 'object' && typeof proxy !== 'string') {
7880
console.log(
7981
chalk.red(

packages/react-scripts/scripts/start.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const config = require('../config/webpack.config.dev');
3636
const devServerConfig = require('../config/webpackDevServer.config');
3737
const createWebpackCompiler = require('./utils/createWebpackCompiler');
3838
const prepareProxy = require('react-dev-utils/prepareProxy');
39+
const url = require('url');
3940

4041
const useYarn = fs.existsSync(paths.yarnLockFile);
4142
const cli = useYarn ? 'yarn' : 'npm';
@@ -52,6 +53,12 @@ const HOST = process.env.HOST || '0.0.0.0';
5253

5354
function run(port) {
5455
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
56+
const formattedUrl = url.format({
57+
protocol,
58+
hostname: HOST,
59+
port,
60+
pathname: '/',
61+
});
5562

5663
// Create a webpack compiler that is configured with custom messages.
5764
const compiler = createWebpackCompiler(
@@ -63,7 +70,7 @@ function run(port) {
6370
console.log();
6471
console.log('The app is running at:');
6572
console.log();
66-
console.log(` ${chalk.cyan(`${protocol}://${HOST}:${port}/`)}`);
73+
console.log(` ${chalk.cyan(formattedUrl)}`);
6774
console.log();
6875
console.log('Note that the development build is not optimized.');
6976
console.log(
@@ -93,7 +100,7 @@ function run(port) {
93100
console.log(chalk.cyan('Starting the development server...'));
94101
console.log();
95102

96-
openBrowser(`${protocol}://${HOST}:${port}/`);
103+
openBrowser(formattedUrl);
97104
});
98105
}
99106

0 commit comments

Comments
 (0)