如何允许本地主机之外的访问 [英] How to allow access outside localhost

查看:375
本文介绍了如何允许本地主机之外的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何允许在Angular2的本地主机之外进行访问?我可以轻松地在localhost:3030/panel上导航,但是在编写诸如10.123.14.12:3030/panel/的IP时却无法导航.

How can I allow access outside the localhost at Angular2? I can navigate at localhost:3030/panel easily but I can not navigate when I write my IP such as 10.123.14.12:3030/panel/.

能否请允许我解决该问题?我没有使用npm(节点项目管理-节点安装/节点启动)来安装和运行项目.

Could you please allow me how to fix it? I am not using npm (node project manage - node install/node start ) to install and run the project.

如果需要,我可以提供我的package.jsonindex.html.

If you want, I can provide my package.json and index.html.

推荐答案

使用ng serve --host 0.0.0.0将允许您使用ip而不是localhost连接到ng serve.

Using ng serve --host 0.0.0.0 will allow you to connect to the ng serve using your ip instead of localhost.

编辑

在较新版本的cli中,您必须提供本地ip地址代替

In newer versions of the cli, you have to provide your local ip address instead

编辑2

在较新版本的cli(我认为是v5及更高版本)中,您可以再次使用0.0.0.0作为ip来托管它,以便网络上的任何人进行通话.

In newer versions of the cli (I think v5 and up) you can use 0.0.0.0 as the ip again to host it for anyone on your network to talk to.

这篇关于如何允许本地主机之外的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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