Install mkcert; Create local certificate authority; Create certificates for your localhost application.
Install mkcert using Homebrew
brew install mkcert brew install nss
Create local certificate authority (CA)
Create certificates for your localhost application
mkcert localhost localhost 127.0.0.1 ::1
Problem: Certificate is invalid. When clicking on the insecure warning next to the address bar to inspect the certificate it shows that it was issued by you computer with mkcert.
Solution: You may have missed the step to make mkcert a local CA.