A, aboutdjango+graphqlCan refer to the use ofportal

Second, set up thedjangoProjects 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,djangothecsrfCross – station attack

  • 1. Specific code

    MIDDLEWARE = [
        ...,
        # 'django.middleware.csrf.CsrfViewMiddleware',. ,]Copy the code

Fifth, invueThe use ofvue-graphqlbridginggraphqlinterfaceRefer to the article

Download the source codeportal