如何在用于ssl测试的dev env中更改angular 4的本地主机名?
我正在尝试将我的主机环境更改为类似www.example.com的内容,而不是如何在用于ssl测试的dev env中更改angular 4的本地主机名?,angular,localhost,Angular,Localhost,我正在尝试将我的主机环境更改为类似www.example.com的内容,而不是localhost/。我试图更改主机文件(sudo nano/private/etc/hosts)中的配置,并执行如下操作,然后清除我的DNS缓存dscacheutil-flushcache,但没有成功。我错过什么了吗 ## # Host Database # # localhost is used to configure the loopback interface # when the system is boo
localhost/
。我试图更改主机文件(sudo nano/private/etc/hosts
)中的配置,并执行如下操作,然后清除我的DNS缓存dscacheutil-flushcache
,但没有成功。我错过什么了吗
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.0.1 www.example.com
255.255.255.255 broadcasthost
::1 localhost
10.211.55.4 window10pro
127.0.0.1 AcronisDriveSearchPlugin
注意,我使用代理配置重定向url调用
{
"/api": {
"target": "https://localhost:5001",
"secure": false
}
}
我的脚本从package.json
"scripts": {
"ng": "ng",
"start": "ng serve --ssl --proxy-config proxy.config.json",....
我调用
npm start
为我的项目提供服务刚刚在angular cli
中的默认值中的配置中的/private/etc/hosts
中添加了相应的主机名(www.example.com
)
"defaults": {
"styleExt": "scss",
"serve": {
"host": "www.example.com",
"sslKey": "server.key",
"sslCert": "server.crt"
},
并在package.json
中修改了我的ng启动脚本
,如下所示
{
"name": "quickstart-angular5",
"version": "5.0.5",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --ssl --proxy-config proxy.config.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build:free": "ngm build -p src/app/typescripts/free --clean && gulp npmFree && gulp startFree && gulp onlyFree",
"build:pro": "ngm build -p src/app/typescripts/pro --clean && gulp only-pro && gulp startPro",
"build:all": "npm run build:free && npm run build:pro",
"aot:build": "ng build --prod --sm=false --aot=true --output-path=dist",
"pre-commit": "ng lint"
},
最后点击npm start
这是在调用ng service
时发生的吗?如果是这样,默认情况下它只在localhost
上侦听。请看一些解决方案