How to use middleware.redirect?

Hi, I am trying to get a HTTPS server with redirection from HTTP and www to the HTTPS non WWW domain. The https://mydomain.com work but not the redirection from the https://www.mydomain.com , http://mydomain.com and http://www.mydomain.com. The https://www.mydomain.com shows the page but doesn’t redirect to https://mydomain.com. The HTTP requests just fail with www.mydomain.com refused to connect.Here is my code:
e := echo.New()
e.Pre(middleware.HTTPSRedirect())
e.Pre(middleware.HTTPSNonWWWRedirect())
serverstarted := e.StartTLS(":443",“cert.pem”,“privkey.pem”)
e.Logger.Fatal(serverstarted)
What am I missing?
Thanks

Is there also a redirect for HTTPS WWW > HTTPS non WWW?
httpS://www.labstack.com > httpS://labstack.com

the HTTPS NonWWW Redirect source is http not https

Thanks