Reputation: 71
I try to open port for using django backend as API at 'http://localhost:3000'
here is my implement
CORS_ALLOWED_ORIGINS = (
'http://localhost:3000'
)
INSTALLED_APPS = [
*
'corsheaders',
]
MIDDLEWARE = [
*
"corsheaders.middleware.CorsMiddleware",# new
"django.middleware.common.CommonMiddleware", # new
*
]
but I keep getting the error message like this
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 version 3.10.6
django version 4.0.6
django-cors-headers version 3.13.0
Upvotes: 7
Views: 8365
Reputation: 130
I think you should use "[" instead of "("
CORS_ALLOWED_ORIGINS = [
'http://localhost:3000'
]
I think that'll do the trick.
If you want Allow all origins you can try this:
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_CREDENTIALS = True
Upvotes: 8