I have a React frontend and a DRF Backend. In the frontend, I am trying to use axios to refresh a JWT access token. The refresh token is sent with every request as an HttpOnly cookie. DRF's Simple JWT library is refreshing the access token. The frontend is hosted on Netlify, which is working, and I am using ngrok to tunnel the backend from my localhost to an https url.
Inside my backend settings.py, I have:
INSTALLED_APPS = [
'corsheaders',
...
]
MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
...
]
CORS_ALLOWED_ORIGINS = [
"https://app.netlify.app", //this is not the actual url, but the format is the same
]
CORS_ALLOW_CREDENTIALS: True
However, whenever I connect to the backend, I get these errors:
XMLHttpRequest cannot load https://ngrokurl/api/token/refresh/ due to access control checks.
Origin https://app.netlify.app is not allowed by Access-Control-Allow-Origin.
Meanwhile, in the backend console, I see that the preflight OPTIONS request returns a 200 status:
[15/Jan/2022 17:47:25] "OPTIONS /api/token/refresh/ HTTP/1.1" 200 0
Not sure if that is anything to do with CORS though.
This is what I am getting:
Error: Image of errors
Request / response: enter image description here
I would greatly appreciate any help; I am quite new to all of this!