kyeon06 / django-sample-project

sample project
0 stars 0 forks source link

🐛 [Bug] CORS Error #15

Closed kyeon06 closed 6 months ago

kyeon06 commented 6 months ago

Describe the bug

CORS ERROR

Attachment

Access to XMLHttpRequest at 'http://34.22.89.60:8000/api/v1/users/login/' from origin 'http://localhost:3000/' has been blocked by CORS policy: Request header field withcredentials is not allowed by Access-Control-Allow-Headers in preflight response.

kyeon06 commented 6 months ago
INSTALLED_APPS = [
    "corsheaders",
]

MIDDLEWARE = [
    "corsheaders.middleware.CorsMiddleware",
]
# CORS_ALLOW_HEADERS = [
#     "accept",
#     "accept-encoding",
#     "authorization",
#     "content-type",
#     "dnt",
#     "origin",
#     "user-agent",
#     "x-csrftoken",
#     "jwt",
#     "withCredentials"
# ]

CORS_ALLOW_CREDENTIALS = True

# CORS_ORIGIN_ALLOW = True

CORS_ALLOWED_ORIGINS = [
    "http://127.0.0.1:3000",
    "http://localhost:3000",
]

# CSRF_TRUSTED_ORIGINS = [
#     "http://127.0.0.1:3000",
#     "http://localhost:3000",
# ]