I am trying to make a GET request in my application that is being served locally (port 8080) using on a node server. I am using Axios to make the request to a django REST server that is also being served locally (port 8000).
My request looks like:
axios.get('http://127.0.0.1:8000/recipes/',{headers: {"Access-Control-Allow-Origin": "*"}})
On the Django side, I've included these in my middleware
MIDDLEWARE = [
'django.middleware.common.CommonMiddleware',
'corsheaders.middleware.CorsMiddleware',
]
and this in my installed apps:
INSTALLED_APPS = [
'corsheaders',
]
And included this setting:
CORS_ORIGIN_ALLOW_ALL = True
But I'm still getting a CORS error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:8000/recipes/. (Reason: missing token ‘access-control-allow-origin’ in CORS header ‘Access-Control-Allow-Headers’ from CORS preflight channel).
Any idea what I'm missing?