Python uses cors to solve cross-domain problems

 download cross-domain

pip install django-cors-headers

Enter in INSTALLED_APPS

'corsheaders',

Add middleware in MIDDLEWARE and put it on the third line

'corsheaders.middleware.CorsMiddleware',

CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = ()
# 对应的发送的请求的跨域
CORS_ALLOW_METHODS = (
    'DELETE',
    'GET',
    'OPTIONS',
    'PATCH',
    'POST',
    'PUT',
    'VIEW',
)

CORS_ALLOW_HEADERS = (
    'accept',
    'accept-encoding',
    'authorization',
    'content-type',
    'dnt',
    'origin',
    'user-agent',
    'x-csrftoken',
    'x-requested-with',
)

Guess you like

Origin blog.csdn.net/Z_Gleng/article/details/129878167