From c5af91c2f37f5dbae72d1f76e3371a2a634f5424 Mon Sep 17 00:00:00 2001 From: Yasuaki Uechi Date: Fri, 7 Feb 2020 12:07:43 +0900 Subject: [PATCH] feat: securing local dev server --- _posts/2020-02-07-secure-dev-server.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 _posts/2020-02-07-secure-dev-server.md diff --git a/_posts/2020-02-07-secure-dev-server.md b/_posts/2020-02-07-secure-dev-server.md new file mode 100644 index 0000000..0f6702c --- /dev/null +++ b/_posts/2020-02-07-secure-dev-server.md @@ -0,0 +1,21 @@ +--- +title: Securing Local Dev Server +--- + +Sometimes you want to interact with a local webserver with https support because of some browser APIs that are only available in an https environment. + +You can easily create a self-signed TLS cert for development purposes with [`mkcert`](https://github.com/FiloSottile/mkcert). + +```shell +brew install mkcert +mkcert -install # Install the local CA in the OS keychain +``` + +After installing `mkcert` and generating system-wide local CA cert, you can create a certificate for each project. + +``` +cd awesome-website +mkcert localhost # this will generate ./localhost.pem and ./localhost-key.pem +npm install -g serve +serve --ssl-cert ./localhost.pem --ssl-key ./localhost-key.pem +```