Доступ к XMLHttpRequest из источника был заблокирован политикой CORS

У меня есть бэкенд на Django 4 и фронтенд на Angular. Django запущен на 192.168.1.195:8080. Angular на 192.168.1.195:4200

Когда я пытаюсь открыть http://192.168.1.195:4200, я получаю

Home:1 Access to XMLHttpRequest at 'http://192.168.1.195:8080/api/hosts_groups' from origin 'http://192.168.1.195:4200' has been blocked by CORS policy: Request header field pragma is not allowed by Access-Control-Allow-Headers in preflight response.

settings.py

ALLOWED_HOSTS = ['192.168.1.195','127.0.0.1','localhost']

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'host_manager.apps.HostManagerConfig',
     # CORS
    'corsheaders',
]

CORS_ALLOWED_ORIGINS = (
    "http://192.168.1.195:4200",
    'http://127.0.0.1:4200',
    'http://localhost:4200'
    )

CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = (
    'http://192.168.1.195:8080',
    'http://192.168.1.195:4200',
    'http://127.0.0.1:4200',
    'http://localhost:4200',
    'http://127.0.0.1:8080',
    'http://localhost:8080'
    )

CORS_ALLOW_HEADERS = (
        'Access-Control-Allow-Headers',
        'Access-Control-Allow-Credentials',
        'Access-Control-Allow-Origin',
        'Access-Control-Allow-Methods'
        )

MIDDLEWARE = [
    # CORS
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    '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',
]

Где я ошибаюсь?

Вернуться на верх