如何从连接到同一网络的另一台计算机打开一个create-react-app? [英] How to open a create-react-app from another computer connected to the same network?

查看:94
本文介绍了如何从连接到同一网络的另一台计算机打开一个create-react-app?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 create-react-app 并将其托管在其默认端口 localhost:3000 中,并希望从其他设备上访问该端口同一网络.

I am using create-react-app and hosting in its default port localhost:3000 and want to access this from another device on the same network.

我获得了主机IP的IP(使用 ifconfig ) 192.168.0.5 ,并尝试打开 192.168.0.5:3000 ,但这没用.

I got the IP of my host's IP (using ifconfig) 192.168.0.5 and tried opening 192.168.0.5:3000 but that did not work.

有什么办法可以做到这一点?

Is there any way to achieve this?

推荐答案

只需运行HOST=0.0.0.0 npm run start.
然后从网络上的另一台设备打开URL.

Simply run HOST=0.0.0.0 npm run start.
Afterwards open the url from another device on the network.

在您的情况下,192.168.0.5:3000将起作用.

In your case, 192.168.0.5:3000 would work.

文档设置HOST环境变量.

Documentation for setting HOST environment variables.

这篇关于如何从连接到同一网络的另一台计算机打开一个create-react-app?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆