DEV Community

Paul Walker
Paul Walker

Posted on • Originally published at on

Using mkcert for testing

I use mkcert and quite a lot for local web development. To avoid gotchas (and because some libraries require it) I often test using HTTPS locally, which means generating a set of certs for each dev install.

The following package.json script will automatically generate cert and key for the domains that you want - set your server to load the same names and cert setup is now a one-liner.

"setup:certs": "mkdir -p certs ; mkcert -cert-file certs/ -key-file certs/ localhost"
Enter fullscreen mode Exit fullscreen mode

(I'm writing this as much so I've got something to copy/paste next time as anything else!)

Top comments (0)