# settings.py
INSTALLED_APPS = [
...
'corsheaders',
...
]
MIDDLEWARE = [
...
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
...
]
# CORS 허용 설정
CORS_ORIGIN_ALLOW_ALL = False # 모든 도메인을 허용하지 않음
CORS_ORIGIN_WHITELIST = [
'http://127.0.0.1:5500', # 허용하고자 하는 도메인 추가
'http://localhost:5500',
]
# 추가 설정 (필요한 경우)
CORS_ALLOW_CREDENTIALS = True
오랜만에 프론트엔드 붙이니까 다음과 같이 에러가 남.
The Cross-Origin-Opener-Policy header has been ignored, because the URL's origin was untrustworthy. It was defined either in the final response or a redirect. Please deliver the response using the HTTPS protocol. You can also use the 'localhost' origin instead.