add cors to main dir, edit headers for cross origin
This commit is contained in:
parent
2dadadb86e
commit
94d1eabc79
0
chaloBEST/cors/__init__.py
Normal file
0
chaloBEST/cors/__init__.py
Normal file
15
chaloBEST/cors/middleware.py
Normal file
15
chaloBEST/cors/middleware.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
from django.http import HttpResponse
|
||||||
|
|
||||||
|
|
||||||
|
class AllowOriginMiddleware(object):
|
||||||
|
def process_request(self, request):
|
||||||
|
if request.method == 'OPTIONS':
|
||||||
|
return HttpResponse()
|
||||||
|
|
||||||
|
def process_response(self, request, response):
|
||||||
|
origin = request.META.get('HTTP_ORIGIN')
|
||||||
|
if origin:
|
||||||
|
response['Access-Control-Allow-Origin'] = origin
|
||||||
|
response['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS, DELETE, PUT'
|
||||||
|
response['Access-Control-Allow-Headers'] = 'Content-Type, Accept'
|
||||||
|
return response
|
Loading…
Reference in New Issue
Block a user