Enabling HTTPS on FastAPI applications
Web applications need security, and Hypertext Transfer Protocol Secure (HTTPS) is a basic way to secure communication between clients and servers.
HTTPS scrambles the data sent over the network, preventing unauthorized access and modification.
In this recipe, we will learn how to enable HTTPS on FastAPI applications for local testing. We’ll use mkcert
to make a Secure Sockets Layer/Transport Layer Security (SSL/TLS) certificate for local development and give some advice for production deployment. By the end of the recipe, you’ll be able to protect your FastAPI application with HTTPS, improving its security and reliability.
Getting ready
Some background information about HTTPS and SSL/TLS certificates can help with this recipe. From a consumer perspective, you can find a good overview at this link: https://howhttps.works/.
We will also use an existing application as an example. You can either apply the recipe to your...