'Easiest/Best way to restrict people/unknown from accessing Django API?

I've written a Django API and it works well however I want to restrict people/unknown hosts from writing requests to the API. This is because I have a React Frontend deployed at example.com and I want to make sure that only example.com can send requests to the API.

I'm not entirely sure how to do this. I was trying to do research into cors however from looking at this thread How can I block calls from unknown domains/IP to my REST API?, it seems like cors can't prevent other hosts/unknown from making requests? I want to secure my API such that only my Frontend host at example.com can make requests to the API and other hosts can't (including stuff like Postman and curl shouldn't be able to make requests).

How do I go about doing this? Any help in the right direction is very much appreciated!

Thank you so much!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source