diff --git a/packages/community-cli-plugin/src/commands/start/index.js b/packages/community-cli-plugin/src/commands/start/index.js index 58b957a8cd1..7cc22efb661 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: 'localhost', + default: '', }, { 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 18540fa1e2c..dc8ac085405 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,13 +63,14 @@ 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: args.host, port}); + const devServerUrl = url.format({protocol, hostname, port}); logger.info(`Welcome to React Native v${ctx.reactNativeVersion}`); @@ -103,7 +104,7 @@ async function runServer( messageSocketEndpoint, eventsSocketEndpoint, } = createDevServerMiddleware({ - host: args.host, + host: hostname, port, watchFolders, });