I just ran an Expo-web development server at http://192.168.0.6:19006
and there appears many problems.
When I did not install django-cors-headers, only the main page was loaded and any others requests all failed. I soon realized that I had to install django-cors-headers. So I did. But then my web app fails to stay logged in. The login process itself is successful on the server side. The client receives a messages telling that the login was successful. But when it transitioned to the next page, it automatically fell back to the main page(as I set) because the app failed to stay logged in. I am assuming that there is something wrong with cookie credentials. But I set the credentials settings like below:
CORS_ORIGIN_WHITELIST = [
'http://192.168.0.6:19006',
]
CORS_ALLOW_CREDENTIALS = True
SESSION_COOKIE_SAMESITE = None
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
...
]
INSTALLED_APPS = [
...
'corsheaders',
]
Another issues is static files are not served with a CORS allowed header. Even if I use django-cors-headers and allow all settings, the static files fail to be loaded with an error message:
Access to XMLHttpRequest at 'http://192.168.0.6:8000/static/app%20Terms%20of%20Service.json' from origin 'http://192.168.0.6:19006' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Why does CORS_ALLOW_CREDENTIALS = True
not work? Or is there something I am missing?