Django utilities for handling Cross-Origin Resource Sharing.
Python
Pull request Compare This branch is 3 commits ahead, 7 commits behind exupero:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cors
.gitignore
README.rst
setup.py

README.rst

django-cors

A Django app for handling Cross-Origin Resource Sharing.

Install by cloning the repo and running

sudo python setup.py install

Then add the app to the installed apps in your settings file:

INSTALLED_APPS = (
    # ...
    'cors',
    # ...
)

To allow requests to be made from the browser from cross domains, use AllowOriginMiddleware:

MIDDLEWARE_CLASSES = (
    # ...
    'cors.middleware.AllowOriginMiddleware',
    # ...
)

and then set ALLOWED_CROSS_DOMAIN_ORIGINS:

#all_origins
ALLOWED_CROSS_DOMAIN_ORIGINS = '*'

#just two subdomains of example.com
ALLOWED_CROSS_DOMAIN_ORIGINS = [
    'http://subdomain1.example.com',
    'http://subdomain2.exapmle.com',
]

#only a single domain
ALLOWED_CROSS_DOMAIN_ORIGINS = 'http://example.com'

cross-domain cookies and credentials can be set with:

ALLOWED_CROSS_DOMAIN_CREDENTIALS = true