Back out "chore(dev-middleware): add localhost as default host in start command config" (#44800)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44800

This is a revert of https://github.com/facebook/react-native/pull/44244, as we've observed [breaking behaviour](https://github.com/facebook/react-native/pull/44244#issuecomment-2078957734) where Android emulators could not connect to the dev server with default settings.

The team doesn't have bandwidth/prio to figure this out with the default `host` value just now, so we are reverting.

Changelog: [Internal] (Nullifies c402dcf)

Reviewed By: cipolleschi

Differential Revision: D58192651

fbshipit-source-id: dd2183d6baa6499ab59e21365adfe62e7a786dfc
This commit is contained in:
Alex Hunt
2024-06-05 09:48:16 -07:00
committed by Facebook GitHub Bot
parent eba1828a83
commit a569c82eb5
2 changed files with 5 additions and 4 deletions
@@ -27,7 +27,7 @@ const startCommand: Command = {
},
{
name: '--host <string>',
default: 'localhost',
default: '',
},
{
name: '--projectRoot <path>',
@@ -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,
});