That happens because of the highly technical details of low level tooling like openssl, keytool and other PKI related details that makes the https protocol work.
Today I discovered that life of a developer got a little bit easier, due to the work of Filippo, here's his article: https://blog.filippo.io/mkcert-valid-https-certificates-for-localhost/
mkcert repo https://github.com/FiloSottile
An excellent tool that most probably will (if not already) be part of the full-stack developer's toolbox.