"OPTIONS /user/signup/ HTTP/1.1" 200 163
κ° λ΄μCORS κ΄λ ¨ μ€μ
μ νλλ ν΄μ£Όμ§ μμ λ°μνλ λ¬Έμ μμ[TIL] OPTIONS
μμ²μ μ λ°μνλκ°?
Django CORS μλ¬ μ²λ¦¬νκΈ°
# settings.py
ALLOWED_HOSTS = ['*']
CORS_ORIGIN_WHITELIST = (
'http://127.0.0.1:5500',
'http://127.0.0.1:8000',
)
CORS_ALLOW_METHODS = (
'DELETE',
'GET',
'OPTIONS',
'PATCH',
'POST',
'PUT',
)
CORS_ALLOW_HEADERS = (
'accept',
'accept-encoding',
'authorization',
'content-type',
'dnt',
'origin',
'user-agent',
'x-csrftoken',
'x-requested-with',
)
CSRF_TRUSTED_ORIGINS = (
'http://127.0.0.1:5500',
)
INSTALLED_APPS = [
'corsheaders',
]
# μμκ° μ€μ! μ μΌ μμ μ μ κ²
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
]
**νλ‘ νΈμλμμλ κ°λ°λͺ
μΈλ₯Ό μ°Έμ‘°νμ¬ μμ±νμ¬μΌ νλ€!**
async function signup(){
const signupData = {
username : document.getElementById("username").value,
password : document.getElementById("password").value,
nickname : document.getElementById("nickname").value,
email : document.getElementById("email").value,
}