1 min read

Using mkcert for testing

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.

I use mkcert and lvh.me 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/appname.lvh.me.pem -key-file certs/appname.lvh.me-key.pem appname.lvh.me localhost"

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