diff --git a/packages/community-cli-plugin/src/commands/start/index.js b/packages/community-cli-plugin/src/commands/start/index.js index 7cc22efb661..58b957a8cd1 100644 --- a/packages/community-cli-plugin/src/commands/start/index.js +++ b/packages/community-cli-plugin/src/commands/start/index.js @@ -27,7 +27,7 @@ const startCommand: Command = { }, { name: '--host ', - default: '', + default: 'localhost', }, { name: '--projectRoot ', diff --git a/packages/community-cli-plugin/src/commands/start/runServer.js b/packages/community-cli-plugin/src/commands/start/runServer.js index 7b11adc629b..15820167a52 100644 --- a/packages/community-cli-plugin/src/commands/start/runServer.js +++ b/packages/community-cli-plugin/src/commands/start/runServer.js @@ -34,7 +34,7 @@ export type StartCommandArgs = { cert?: string, customLogReporterPath?: string, experimentalDebugger: boolean, - host?: string, + host: string, https?: boolean, maxWorkers?: number, key?: string, @@ -63,14 +63,13 @@ async function runServer( projectRoot: args.projectRoot, sourceExts: args.sourceExts, }); - const hostname = args.host?.length ? args.host : 'localhost'; const { projectRoot, server: {port}, watchFolders, } = metroConfig; const protocol = args.https === true ? 'https' : 'http'; - const devServerUrl = url.format({protocol, hostname, port}); + const devServerUrl = url.format({protocol, hostname: args.host, port}); logger.info(`Welcome to React Native v${ctx.reactNativeVersion}`); @@ -104,7 +103,7 @@ async function runServer( messageSocketEndpoint, eventsSocketEndpoint, } = createDevServerMiddleware({ - host: hostname, + host: args.host, port, watchFolders, });