npm http-server with SSL

前端 未结 4 1845
忘掉有多难
忘掉有多难 2021-01-29 19:44

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 i

4条回答
  •  时光取名叫无心
    2021-01-29 20:34

    I installed mkcert:

    brew install mkcert
    brew install nss # if you use Firefox
    
    mkcert -install
    

    Then, in your project directory:

    mkcert 0.0.0.0 localhost 127.0.0.1 ::1
    

    Finally, I renamed generated files:

    • 0.0.0.0+3-key.pem -> key.pem
    • 0.0.0.0+3.pem -> cert.pem

    And ran the following command:

    http-server -S -C cert.pem -o
    

    Then I got:

    enter image description here

    I referenced this blog: https://qiita.com/walkers/items/b90a97a99bbb27f6550f (written in Japanese)

提交回复
热议问题