| 1 min read

一般我们本地预览的时候,一般就用 localhost + 端口 就行了,再有需要的话,会类似修改 Hosts ,然后进行域名的绑定

127.0.0.1  dev.xxxx.com

这样我们可以借助本地 hosts 来实现对域名访问本地的服务。

借助 Fiddler 或者 Charles 可以实现代理,从而让手机进行域名的访问。

不过我们有的时候需要访问 https 的服务。 这个时候相对来说,我们可以在使用 serve 基础上,安装 https-localhost 来进行服务的启动。

在这之前,我们也需要安装 nss

brew install nss

然后,我们执行 npm 安装命令就好。

npm i -g --only=prod https-localhost

安装完成后,这个时候我们进入目录。

serve ./

如果我们看到这些字样

Serving static path: /Users/www/freleap.github.io
http to https redirection active.
Server running on port 443.

差不多就可以,我们可以输入本地的域名

https://dev.xxxx.com

进行访问了。

You Can Speak "Hi" to Me in Those Ways