참고-장고(CORS 셋팅)

JungSik Heo·2024년 12월 24일

1. Django-cors-headers 설치

pip install django-cors-headers

2.settings.py에 설정추가

INSTALLED_APPS =[ 
	#... 
	'corsheaders'
	]
MIDDLEWARE = [
	'corsheaders.middleware.CorsMiddleware', #최상단에 추가해주기
	#...
]
CORS_ALLOWED_ORIGINS = [
	# 허용할 Origin 추가
    "https://example.com",
    "https://sub.example.com",
    "http://localhost:8080",
    "http://127.0.0.1:9000"
]
상황에 따라 모든 도메인에 대해서도 추가가 가능합니다
CORS_ORIGIN_ALLOW_ALL = True
profile
쿵스보이(얼짱뮤지션)

0개의 댓글