DEV Community

Paul Walker
Paul Walker

Posted on • Originally published at solarwinter.net on

Using mkcert for testing

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"
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)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay