Skip to content

How to launch a secure local web server (HTTPS)

Lloyd Brookes edited this page Jun 21, 2017 · 6 revisions

Some modern techs (ServiceWorker, any MediaDevices.getUserMedia() request etc.) must be served from a secure origin (HTTPS). To launch an HTTPS server, supply a --key and --cert to local-web-server, for example:

$ ws --key server.key --cert server.crt

Alternatively, use PFX file:

$ ws --pfx server.pfx

If you don't have a key and certificate it's trivial to create them.

Built-in certificate

As a quick win, you can run ws with the https flag. This will launch an HTTPS server using a built-in certificate registered to the domains 127.0.0.1 and localhost.

Clone this wiki locally