我正在尝试重命名我在开发中使用的localhost
。
我已经更新了我的C:\Windows\System32\drivers\etc\hosts
文件并添加了这一行(以管理员身份运行:]
# copyright (c) 1993-2009 microsoft corp.
#
# this is a sample hosts file used by microsoft tcp/ip for windows.
#
# this file contains the mappings of ip addresses to host names. each
# entry should be kept on an individual line. the ip address should
# be placed in the first column followed by the corresponding host name.
# the ip address and the host name should be separated by at least one
# space.
#
# additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# for example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within dns itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 my-dev-environment.com // <===== ADDED THIS LINE
127.0.0.1:8080 my-dev-environment.com // <===== I ALSO TRIED THIS
但是我仍然收到此错误:
This site can’t be reached
"my-dev-environment.com" refused to connect
我正在使用webpack-dev-server
进行开发,这是我目前的配置:
webpack.config.js
devServer: {
contentBase: './public',
compress: true,
hot: true,
historyApiFallback: {
index: '/app.html'
},
index: 'app.html'
},
问题
我做错什么了吗?为什么不起作用?
更新(已解决):
根据下面答案中的@Joel建议,我已将其添加到我的webpack.config.js
devServer: {
public: 'my-dev-environment.com',
port: 80,
}
这是在我的hosts
文件中:
127.0.0.1 my-dev-environment.com
现在我可以在my-dev-environment.com
上访问它>
我正在尝试重命名用于开发的本地主机。我已经更新了C:\ Windows \ System32 \ drivers \ etc \ hosts文件,并添加了以下这一行(以管理员身份运行):#copyright(c)1993-2009 ...
在主机