Django CORS Headers


1. Allow all origins and methods

CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_METHODS = [
    'DELETE',
    'GET',
    'OPTIONS',
    'PATCH',
    'POST',
    'PUT',
]

2. Allow specific origins

CORS_ALLOWED_ORIGINS = [
    "https://example.com",
    "https://foo.example.com",
    "https://bar.example.com",
]

3. Allow specific origins with GET and POST methods

CORS_ALLOWED_ORIGINS = [
    "https://example.com",
]
CORS_ALLOW_METHODS = ['GET', 'POST']

4. Allow all origins with GET and POST methods

5. Allow all origins and specific methods

6. Allow all origins, specific methods, and specific headers

7. Allow specific origins, specific methods, and specific headers

8. Allow all origins and expose specific headers

9. Allow specific origins and expose specific headers

10. Allow all origins with credentials and specific methods

11. Allow specific origins with credentials and specific methods

12. Allow all origins with credentials, specific methods, and specific headers

13. Allow specific origins with credentials, specific methods, and specific headers

14. Allow all origins with credentials, expose specific headers, and max age

15. Allow specific origins with credentials, expose specific headers, and max age

16. Allow all origins with preflight requests and specific headers

17. Allow specific origins with preflight requests and specific headers

18. Allow all origins with preflight requests and expose specific headers

19. Allow specific origins with preflight requests and expose specific headers

20. Allow all origins with preflight requests, expose specific headers, and max age

21. Allow specific origins with preflight requests, expose specific headers, and max age

22. Allow all origins with credentials, specific methods, and preflight requests

23. Allow specific origins with credentials, specific methods, and preflight requests

24. Allow all origins with credentials, expose specific headers, and preflight requests

25. Allow specific origins with credentials, expose specific headers, and preflight requests

26. Allow all origins with credentials, expose specific headers, preflight requests, and max age

27. Allow specific origins with credentials, expose specific headers, preflight requests, and max age

28. Allow all origins with credentials, specific methods, preflight requests, and expose specific headers

29. Allow specific origins with credentials, specific methods, preflight requests, and expose specific headers

30. Allow all origins with credentials, preflight requests, expose specific headers, and max age

31. Allow specific origins with credentials, preflight requests, expose specific headers, and max age

32. Allow all origins with credentials, specific methods, preflight requests, expose specific headers, and max age

33. Allow specific origins with credentials, specific methods, preflight requests, expose specific headers, and max age

34. Allow all origins with preflight requests, expose specific headers, and max age

35. Allow specific origins with preflight requests, expose specific headers, and max age

36. Allow all origins with preflight requests, expose specific headers, and max age