After a few days of struggling I finally found a way to run localhost with https. I guess this solution will work on any macOS version.
from: https://letsencrypt.org/docs/certificates-for-localhost/
I found this minica tool which is a simple CA intended for use in situations where the CA operator also operates each host where a certificate will be used. It automatically generates both a key and a certificate when asked to produce a certificate. It does not offer OCSP or CRL services. Minica is appropriate, for instance, for generating certificates for RPC systems or microservices.
https://github.com/jsha/minica
Step 1
brew install minica
Step 2
minica --domains localhost
Generate a root key and cert in minica-key.pem, and minica.pem, then
generate and sign an end-entity key and cert, storing them in
./localhost/

Step 3
add those cert and key files into your config server file. For example configure in: /etc/apache2/extra/httpd-ssl.conf
<VirtualHost _default_:443>
DocumentRoot "/Volumes/WORK/www/webapp"
ServerName localhost
SSLEngine on
SSLCertificateFile /Users/xxxx/selfsigned-certs/localhost/cert.pem
SSLCertificateKeyFile /Users/xxxx/selfsigned-certs/localhost/key.pem
<Directory "/Volumes/WORK/www/webapp">
Options All
MultiviewsMatch Any
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Step 4
Restart server
Step 5
in Keychain Access ---> File ---> Import Items
import "minica.pem" file

Step 6
in Chrome browser when accessing the https://localhost you will get a message with a not trusted certificate
to make it a trusted you must go to:
chrome://settings/security --> "Manage certificates"
from there open the "minica..." certificate and set it as trusted

Step 7
reopen https://localhost ---> it will recognise certificate as valid and trusted one


Happy coding!