A, aboutdjango+graphql
Can refer to the use ofportal
Second, set up thedjango
Projects allow cross-domain access
-
1. Reference documents
-
2. Installation package
pip install django-cors-headers Copy the code
-
3. Register in the app
INSTALLED_APPS = ( ... 'corsheaders',...).Copy the code
-
4. Add code to middleware
MIDDLEWARE = [ # Or MIDDLEWARE_CLASSES on Django < 1.10.'corsheaders.middleware.CorsMiddleware'.'django.middleware.common.CommonMiddleware'. ]Copy the code
-
5, set
CORS_ORIGIN_ALLOW_ALL = True Copy the code
Three, cancellation,django
thecsrf
Cross – station attack
-
1. Specific code
MIDDLEWARE = [ ..., # 'django.middleware.csrf.CsrfViewMiddleware',. ,]Copy the code