https for local development

  • Use mkcert

    mkcert -install
    mkcert localhost # creates two localhost.pem (cert) and localhost-key.pem (key) file
    
  • provide the key and cert file to the http server program. For example in python if using uvicorn:

    uvicorn.run("api.main:app", host="0.0.0.0", ssl_keyfile=key_path, ssl_certfile=cert_path, reload=True)
    

Also read

  1. How to Create Your Own SSL Certificate Authority for Local HTTPS Development
  2. How to Run HTTPS on Localhost: A Step-by-Step Guide