mkcert -install
mkcert localhost 127.0.0.1 ::1 myapp.test
The first command creates a local certificate authority and adds it to your system and browser trust stores. The second writes localhost+3.pem and localhost+3-key.pem, signed by that authority, so browsers on this machine trust them.
Point your server at them, for example in a Vite config:
server: {
https: {
cert: './localhost+3.pem',
key: './localhost+3-key.pem',
},
}
Install it with brew install mkcert, choco install mkcert or your distro's package. Don't commit the key files, and never use this authority for anything but your own machine. Some things (the clipboard API, service workers, geolocation) only work on HTTPS, which is usually why you end up here.