本地启用支持 https 的 Web 服务器

    xiaoxiao2022-07-05  158

    首先打开命令行窗口,进入项目 目录,通过 npm 安装 http-server 包: $ cd project $ npm install -g http-server 接着通过 openssl 创建私钥和证书: $ openssl genrsa 2048 > key.pem $ openssl req -x509 -days 1000 -new -key key.pem -out cert.pem 当私钥和证书准备就绪后,可通过 SSL 在本地启动 Web 服务: $ http-server --ssl -c-1 -p 8080 -a 127.0.0.1 $ http-server --ssl
    最新回复(0)