I have been struggling with a CORS issue with login form POST request coming from React dev server to my django backend where I am using Django’s LOginView module for login requests API. These are my settings for settings.py CORS_ALLOW_METHODS = ( “DELETE”, “GET”, “OPTIONS”, “PATCH”, “POST”, “PUT”, ) CORS_ALLOW_HEADERS = ( “accept”, “authorization”, “content-type”, “user-agent”, “x-csrftoken”, “x-requested-with”, ) CORS_ALLOWED_ORIGINS = [ ‘http://localhost:3000’,
]
CORS_TRUSTED_ORIGINS = [ ‘localhost:3000’,
] CSRF_TRUSTED_ORIGINS = [ ‘localhost:3000’, ] CORS_ORIGINS_WHITELIST = [ ‘localhost:3000’,
] and for react I am implementing a proxy in package.json “proxy”: “localhost:8000/”, my api for user token retrieval works fine but I believe something is wrong with the CSRF verification. Kindly take a look at the title for the arisen error. Thanks.
I have alreaady tried the settings reffered in documentation : django-cors-headers · PyPI and someone facing the similar problem in the forumas well.