I’m having similar problems to many people with cors-headers but despite reading lots of stackoverflow and the project docs I can’t get it to work
To start with, I am running
Django==4.2.5
django-cors-headers==4.2.0
The problem is simple, when I attempted to add <link rel="manifest" href="{% static 'site.webmanifest' %}">
to one of my files to access a static file, I get a cors header error when chrome reaches this line: “Ensure CORS response header values are valid”. The file is stored on GCP storage <link rel="manifest" href="https://storage.googleapis.com/mydirectory/site.webmanifest">
So I know that I am supposed to be able to solve this by allowing google storeage as a valid origin in my settings.py when I configure django-cors-headers… however even if I just brute force it for debugging and allow all I still get the same error
So in settings.py I have:
CORS_ALLOW_ALL_ORIGINS = True # debugging only obviously
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'bootstrap5',
'easy_thumbnails',
'properties',
'django_extensions',
'corsheaders',
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
I am baffled why CORS_ALLOW_ALL_ORIGINS=True doesn’t work since I have corsheaders as my very first middleware item and corsheaders is listed in our installed apps. So it seems like I’ve done the standard stuff, but when I deploy to app engine and test it out nothing changes no matter what I do.
Help?