Even after installing CORS middle ware and enabling Cross Origin Requests also. I am unable to make a post request by using Javascript.
const csrf = Cookies.get('csrftoken');
return {
'X-CSRFToken' : csrf,
'Access-Control-Allow-Origin':"*"
"Access-Control-Allow-Headers":"Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers"};
And also in Django app
CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = (
'127.0.0.1',
)
CORS_ALLOW_HEADERS = (
'x-requested-with',
'content-type',
'accept',
'origin',
'authorization',
'x-csrftoken',
'x-api-key'
)
And also after adding CORS Middleware,
MIDDLEWARE_CLASSES = ('corsheaders.middleware.CorsMiddleware')