Django Cors 설치 및 설정

김회민·2022년 4월 18일
0

설치

# Bash
> pip install django-cors-headers

설정

# /mysite/settings.py
from corsheaders.defaults import default_headers

# Application definition
INSTALLED_APPS = [
    'corsheaders',
    # ...
]

MIDDLEWARE = [
    'corsheaders.middleware.CorsMiddleware',
    # ...
]

# CORS
CORS_ORIGIN_WHITELIST = [
    'http://localhost:3000',
]
CORS_ALLOW_CREDENTIALS = True
CORS_ALLOW_HEADERS = list(default_headers) + [ 'token' ]
profile
백엔드 개발자 지망생

0개의 댓글