带SSL的npm http服务器 [英] npm http-server with SSL
问题描述
我正在使用npm软件包"http-server"( https://www.npmjs .com/package/http-server )来设置一个简单的网络服务器,但我无法使用SSL.我在package.json中的命令是
I'm using the npm package "http-server" (https://www.npmjs.com/package/http-server) to set up a simple webserver, but I cannot get it to use SSL. My command in package.json is
http-server -p 8000 -o -S
在我的根目录中(现在)带有cert.pem和key.pem. "-o"选项将浏览器打开到默认页面,但是该页面是使用HTTP服务的,甚至无法通过HTTPS访问.我没有收到任何错误或警告.我也尝试过添加"-C"和"-K"选项而没有运气.有没有人成功使用过此软件包?
with a cert.pem and key.pem in my root directory (for now). The "-o" option opens a browser to the default page, but the page is served using HTTP and not even accessible through HTTPS. I don't get any errors or warnings. I've also tried adding the "-C" and "-K" options without luck. Has any one had any success with this package?
推荐答案
仅供以后参考,我的问题已通过将软件包更新为package.json中的最新版本来解决.我复制粘贴了一个旧的示例文件,而没有更新版本号.
Just for future reference, my problem was solved by updating the package to the latest version in package.json. I copy-pasted an old example file without updating the version numbers.
这篇关于带SSL的npm http服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!