react-native
react-native copied to clipboard
chore(dev-middleware): add `localhost` as default host in `start` command config
Summary:
Inside Re.Pack we consume command's options, to reduce the amount of assumptions that 3rd party tools need to make - we can move assigning default value to config command level, so default values will be aligned across tools.
For default start command this change doesn't change any behaviour.
Changelog:
[INTERNAL] [CHANGED] - Add localhost as default host in start command config
Test Plan:
start command should work the same way as before.
cc @huntie
@blakef has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
@blakef merged this pull request in facebook/react-native@c402dcfe5738174d28ac6d00bc82dad99949e376.
This pull request was successfully merged by @szymonrybczak in c402dcfe5738174d28ac6d00bc82dad99949e376.
When will my fix make it into a release? | How to file a pick request?
Hey @szymonrybczak, there's one more line where args.host is referenced: https://github.com/facebook/react-native/blob/ed815fcd9da7c4d3d73d52960118bf37adba321e/packages/community-cli-plugin/src/commands/start/runServer.js#L145
Before your change, an empty string was passed there by default, but now it receives localhost. At least for me, this breaks the default behavior when running on an Android emulator, and it cannot connect to the dev server. We also tried on RN 0.74, and running dev server with --host localhost behaves differently than the default - android emulator cannot connect to the dev server then, though it works on a physical device.
can confirm that's a breaking change toward android emulators. i guess the localhost on modern macos resolved to ipv6 ::1 which is not recognized by android emulators 10.0.2.2 loopback.
either way works:
yarn start --host '127.0.0.1'yarn start --host '0.0.0.0'
I think we'll revert this change to conform to the previous behaviour. We probably need a more intricate change to simplify this default while supporting Android.
cc @cortinico @szymonrybczak