Enabling CORS and HTTPS
CORS protection and HTTPS support are two things considered critical in any running production application. This section will explain how can we add them to the application that we're building.
There are many other security practices that can be added to any API. As those aren't Deno specifics and deserve a book by themselves, we decided to focus on these two elements.
We'll begin by learning about CORS and how can we leverage oak
and the middleware function feature we know in order to do it. Then, we'll learn how can we also use a self-signed certificate and make our API handle secure HTTP connections.
Let's go, starting with CORS.
Enabling CORS
If you are not familiar with CORS, it is a mechanism that enables a server to indicate to browsers which origins they should allow resource loading from. When the application is running on the same domain as the API, CORS is not even necessary, as the name directly makes explicit...