本地开发Host配置
2024/5/8·3 views
在本地开发的时候我更倾向于配置一个域名指向本地用来调试,有好几种方法来进行配置实现。
-
泛解析域名到
127.0.0.1,例如*.dev.codeemo.cn -
使用
SwitchHost等工具进行Host配置, 将每个域名指向本地 -
在
Windows下可以使用.localhost后缀的域名,例如 cms.localhost,这个是可以不配置host直接使用的
同时对于.localhost的域名还可以生成证书,传送门
生成的证书配置好后会提示
Your connection is not private
Attackers might be trying to steal your information from test.localhost (for example, passwords, messages, or credit cards). Learn more
NET::ERR_CERT_COMMON_NAME_INVALID
,还没研究怎么解决,直接点高级进去就可以了。顺便记录一下,如果不是本地域名并且证书不安全,会没有Proceed to test.localhost (unsafe),可以直接盲输入 thisisunsafe就可以看到直接进入页面了。如果页面有请求接口,接口可能会被拦截,可以将接口在地址栏打开,点击Proceed to test.localhost (unsafe) 即可