当前位置 : 主页 > 编程语言 > python >

使用django-cors-headers 来解决跨域问题

来源:互联网 收集:自由互联 发布时间:2021-06-25
ALLOWED_HOSTS = ["*"] # Application definition INSTALLED_APPS = [ ‘django.contrib.admin‘, ‘django.contrib.auth‘, ‘django.contrib.contenttypes‘, ‘django.contrib.sessions‘, ‘django.contrib.messages‘, ‘django.contrib.stat
ALLOWED_HOSTS = ["*"]


# Application definition

INSTALLED_APPS = [
‘django.contrib.admin‘,
‘django.contrib.auth‘,
‘django.contrib.contenttypes‘,
‘django.contrib.sessions‘,
‘django.contrib.messages‘,
‘django.contrib.staticfiles‘,

‘graphene_django‘,
‘corsheaders‘, *************
]

# 允许跨域设置CORS_ALLOW_CREDENTIALS = TrueCORS_ORIGIN_ALLOW_ALL = TrueSESSION_COOKIE_HTTPONLY = FalseSESSION_COOKIE_SAMESITE = NoneCORS_ALLOW_METHODS = (    ‘DELETE‘,    ‘GET‘,    ‘OPTIONS‘,    ‘PATCH‘,    ‘POST‘,    ‘PUT‘,    ‘VIEW‘,)CORS_ALLOW_HEADERS = (    ‘XMLHttpRequest‘,    ‘X_FILENAME‘,    ‘accept-language‘,    ‘accept-encoding‘,    ‘authorization‘,    ‘content-type‘,    ‘dnt‘,    ‘origin‘,    ‘user-agent‘,    ‘x-csrftoken‘,    ‘x-requested-with‘,    ‘Pragma‘,)
上一篇:python:日期计算
下一篇:Python 定时调度
网友评论