Background processing across domains
'' '
Https://github.com/ottoyiu/django-cors-headers/ mounted django-corsheaders modules disposed in the settings.py # Register App the INSTALLED_APPS = [ ... ' corsheaders' ] # added intermediate member MIDDLEWARE = [ ... 'corsheaders.middleware.CorsMiddleware' ] # permit cross source CORS_ORIGIN_ALLOW_ALL = False # cross-domain configuration specifies the domain name CORS_ORIGIN_WHITELIST = [ 'http://example.com' ] # allow ajax request carries the cookie CORS_ALLOW_CREDENTIALS = True # Note: reception request header carries parameters, middleware refused Access-Control-Allow-Headers error, middleware to set default_headers from corsheaders Import Defaults
Add default_headers the 'inside the distal ajax request header field name'
'' '
Foreground processing ajax
"" "
1. Install Axios
CNPM the install Axios --save 2. src / main.js configuration included cookie when ajax // allow transmission request axios.defaults.withCredentials = to true; Vue.prototype $ = Axios Axios;. @ the object is mounted in vue # axios occurs ajax request $ Axios ({ UTL: 'http://api.example.com/test', // request interface headers: {}, // carrying the request header method: ' post ', // may also be POST data: {}, // by GET param: {} submit data }) "" "