Hello guys i have a problem. I don’t know how to describe my problem but let me explain my project first. I have a simple project and i’m using google cloud sql for static and media files (And i’ll deploy on google). And before i move my static files to google cloud sql everything was good but now i have this error (30+ error):
(index):1 Access to font at ‘https://storage.googleapis.com/static/Fonts/jost/Jost-400-Book.ttf’ from origin ‘http://127.0.0.1:8000’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
And after little bit search i find django-cors-headers and i fallowed what their intrudction said. here’s my settings codes:
ALLOWED_HOSTS = ['*']
CORS_ORIGIN_ALLOW_ALL = True
INSTALLED_APPS = [
'honeypot',
'ckeditor',
'ckeditor_uploader',
'modeltranslation',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'corsheaders',
'Product.apps.ProductConfig',
'captcha',
'admin_honeypot',
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
...
STATIC_URL = 'https://storage.googleapis.com/{}/'.format(GS_STATIC_BUCKET_NAME)
STATIC_ROOT = "static/"
MEDIA_URL = 'https://storage.googleapis.com/{}/'.format(GS_MEDIA_BUCKET_NAME)
MEDIA_ROOT = 'media/'
I hope someone can help me because i don’t even know what cors is.