jquery - Cannot get CORS to work with contenType - Django Rest Framework -


i have been wasting whole day on stupid little issue!

i'm using django-rest-framework api , backbone.js in front end.

i cannot request server when adding option contenttype.

here simple example of i'm trying do:

$.ajax     url:"http://127.0.0.1:8080/foo/"     type:"post"     data: '{"e":"e"}'     contenttype: "application/json" 

the options fails , post never sent.

the options request headers:

access-control-request-headers:accept, origin, content-type access-control-request-method:post origin:http://localhost:8000 

now don't know why options fail. i'm using corsheaders app django, , settings follows:

cors_origin_allow_all = true cors_allow_headers = (     'x-requested-with',     'content-type',     'accept',     'origin',     'authorization' ) 

cors_origin_allow_all = true 

is enough if have following setup correctly

installed_apps = (     *     'corsheaders', )  middleware_classes = (     *     'corsheaders.middleware.corsmiddleware',     'django.middleware.common.commonmiddleware', ) 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -