allow cross origin content-type header

This commit is contained in:
j 2018-01-12 11:35:37 +01:00
parent b6dcccb230
commit f44584f131

View file

@ -17,6 +17,8 @@ def api(request):
response = render_to_json_response({'status': {'code': 200, response = render_to_json_response({'status': {'code': 200,
'text': 'use POST'}}) 'text': 'use POST'}})
response['Access-Control-Allow-Origin'] = '*' response['Access-Control-Allow-Origin'] = '*'
response['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS'
response['Access-Control-Allow-Headers'] = 'Content-Type'
return response return response
if request.META['REQUEST_METHOD'] != "POST" or ( if request.META['REQUEST_METHOD'] != "POST" or (
not 'action' in request.POST and request.META.get('CONTENT_TYPE') != 'application/json' not 'action' in request.POST and request.META.get('CONTENT_TYPE') != 'application/json'