python django vue 跨域请求(这样跨域是成功的),前端请求不携带cookie
前端 vue:
import axios from 'axios'
Vue.prototype.$axios=axios
// 跨域 前端请求携带cookie 设置
axios.defaults.withCredentials=true
+
后端 django:
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = True
Resquest Headers
Accept: 。
Accept-Encoding: 。
Accept-Language: 。
Connection: keep-alive
Content-Length: 24
Content-Type: application/x-www-form-urlencoded
Host: 127.0.0.1:8000
Origin: http://localhost:8080
Referer: http://localhost:8080/
sec-ch-ua: 。
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
User-Agent: 。
我想在后端的一个视图类中设置session数据,然后在另一个视图类中获取设置的 session数据
settings.py里添加个配置试试:
SESSION_COOKIE_SECURE = False