2.6. HTTP CORS¶
CORS in 100 Seconds: https://www.youtube.com/watch?v=4KHiSt0oLJ0
2.6.1. OPTIONS and CORS¶
http_method_names = ['get', 'post', 'options']
def options(self, request, *args, **kwargs):
response = HttpResponse(status=200)
response['Access-Control-Allow-Origin'] = '*'
response['Access-Control-Allow-Methods'] = ', '.join(http_method_names).upper()
response['Access-Control-Allow-Headers'] = 'Content-Type'
return response