Corsheaders.E013 ошибка в заголовках django cors
Я пытаюсь открыть порт для использования бэкенда django в качестве API на 'http://localhost:3000'
вот моя реализация
CORS_ALLOWED_ORIGINS = (
'http://localhost:3000'
)
INSTALLED_APPS = [
*
'corsheaders',
]
MIDDLEWARE = [
*
"corsheaders.middleware.CorsMiddleware",# new
"django.middleware.common.CommonMiddleware", # new
*
]
но я продолжаю получать сообщение об ошибке следующего содержания
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
?: (corsheaders.E013) Origin '/' in CORS_ALLOWED_ORIGINS is missing scheme or netloc
HINT: Add a scheme (e.g. https://) or netloc (e.g. example.com).
?: (corsheaders.E013) Origin '/' in CORS_ALLOWED_ORIGINS is missing scheme or netloc
HINT: Add a scheme (e.g. https://) or netloc (e.g. example.com).
?: (corsheaders.E013) Origin '0' in CORS_ALLOWED_ORIGINS is missing scheme or netloc
HINT: Add a scheme (e.g. https://) or netloc (e.g. example.com).
?: (corsheaders.E013) Origin '0' in CORS_ALLOWED_ORIGINS is missing scheme or netloc
HINT: Add a scheme (e.g. https://) or netloc (e.g. example.com).
.
.
.
.
.
.
System check identified 21 issues (0 silenced).
PS.
python версии 3.10.6
django версия 4.0.6
django-cors-headers версия 3.13.0
Я думаю, вам следует использовать "[" вместо "("
CORS_ALLOWED_ORIGINS = [
'http://localhost:3000'
]
Думаю, это поможет.
Если вы хотите разрешить все источники, вы можете попробовать следующее:
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_CREDENTIALS = True