장고 백엔드API서버/프론트엔드가 서로 통신할 때,
도메인 밖의 다른 도메인으로부터 요청할 수 있게 허용하는 것
🔹설치
pip install django-cors-headers
INSTALLED_APPS =[
...
'corsheaders',
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware', # middleware 최상단에 추가
...
]
CORS_ORIGIN_WHITELIST = ['http://127.0.0.1:3000'
,'http://localhost:3000'] # 허용할 frontend 도메인
CORS_ALLOW_CREDENTIALS = True