$http({
url: url,
method: "POST",
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'withCredentials': true,
'X-CSRFToken':$cookies.csrftoken
},
data: {
"username":username,
"password":password
},
})
.then(function (response) {
},
function (response) {
});
我发送一个像这样的http请求,希望它有标题:
X-CSRFToken:3PTP6eV9rEDHvhBxOxRMOKhXb26zKpMOyBAMdhbaZAxnGxCxsISb5KUJOMCkfxO1
但得到:
Access-Control-Request-Headers:withcredentials,x-csrftoken
我的问题是如何从访问控制请求标题中获取x-csrftoken
我试过了:
$http.defaults.headers.post['X-CSRFToken'] = $cookies.csrftoken;