Hey guys,
I am developing a React webapp using Nx. I require this app to test on phone. But I cannot access it over wi-fi using the ip address. Is there a way to ensure nx binds to 0.0.0.0 instead of localhost so that I can access it using http://192.168.0.102:4200 ?
This is how netstat looks like
tcp4 0 0 192.168.0.102.63776 104.21.212.16.https ESTABLISHED
tcp4 0 0 localhost.4200 localhost.63645 ESTABLISHED
tcp4 0 0 localhost.63645 localhost.4200 ESTABLISHED
Can you try running this command, and let me know how it goes?
yarn nx serve --host=0.0.0.0
Unfortunately because of this this won't work: https://github.com/nrwl/nx/blob/master/packages/web/src/builders/dev-server/dev-server.impl.ts#L80
We should remove it.
@naishe I think the only way for now is to update your /etc/hosts to remap localhost to 0.0.0.0.
You can also write a postinstall script that will update the node moduels and will replace:
hostname:
serveOptions.host === '0.0.0.0' ? 'localhost' : serveOptions.host,
with
hostname:
serveOptions.host === '0.0.0.0' ? '0.0.0.0' : serveOptions.host,
Fixed by #2129
still can't reach it over wifi using the ip address.
i had to do...
yarn nx serve --host 0.0.0.0 --publicHost dev.local
(i mapped dev.local to the ip address of my dev box on my dev machine in /etc/hosts, prolly would work with ip address.)
Most helpful comment
Can you try running this command, and let me know how it goes?