A Django App that adds Cross-Origin Resource Sharing (CORS) headers to
responses. This allows in-browser requests to your Django application from
other origins.
Improve your Django and Git skills with my books.
About CORS
Adding CORS headers allows your resources to be accessed on other domains. It’s
important you understand the implications before adding the headers, since you
could be unintentionally opening up your site’s private data to others.
Some good resources to read on the subject are:
Julia Evans’ introductory comic and
educational quiz.
Jake Archibald’s How to win at CORS
The MDN Article
The HTML5 Rocks Tutorial
The Wikipedia Page
Requirements
Python 3.8 to 3.12 supported.
Django 3.2 to 5.0 supported.
Setup
Install from pip:
python -m pip install django-cors-headers
and then add it to your installed apps:
INSTALLED_APPS = [
...,
"corsheaders",
...,
]
Make sure you add the trailing comma or you might get a ModuleNotFoundError
(see this blog
post).
You will
|