出于开发目的,我想打开本地主机以外的我的有角度的应用程序,但是遇到以下错误,如何修复该错误的任何指导?
username$ ng serve --open --host=ibaitdev.company.com
getaddrinfo ENOTFOUND ibatdev.company.com
Error: getaddrinfo ENOTFOUND ibatdev.company.com
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
我如下更改了/etc/hosts
#
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 ibaitdev.company.com
255.255.255.255 broadcasthost
::1 ibaitdev.company.com
答案 0 :(得分:2)
使用ng serve --host 0.0.0.0 --disable-host-check
将允许您使用IP 0.0.0.0(而不是localhost)连接到服务器。
这将禁用主机检查,并允许使用IP地址而不是localhost从外部进行访问。
在较新版本的AngularCLI(高于v5)中,您可以再次使用0.0.0.0作为IP将其托管在网络上。
答案 1 :(得分:0)
您可以提供--host = 127.0.0.1 然后,当您转到浏览器时,只需转到该域名即可。 (127.0.0.1:4200)