【发布时间】:2020-06-27 13:24:18
【问题描述】:
我正在使用 axios 尝试登录 COD 网站以获取 XSRF 令牌以验证 Node 中的请求。
我可以正常登录,但是在 Chrome 中检查流量时,我可以看到我在下面调用的页面返回 302 重定向,但在标头中,包括所有包含 XSRF 的 set-cookie 标头我需要捕获的令牌
const loginReq = await axios({
method: "post",
url: "https://profile.callofduty.com/do_login?new_SiteId=cod",
data: `username=foo&remember_me=true&password=bar%21&_csrf=${csrf}`,
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.102 Safari/537.36 Vivaldi/2.0.1309.37",
"Referer": "https://profile.callofduty.com/cod/login?redirectUrl=https%3A%2F%2Fwww.callofduty.com%2F",
"Origin": "https://profile.callofduty.com",
"Content-Type": "application/x-www-form-urlencoded",
"Cookie": cookie.join(';')
}
});
我遇到的问题是我的 Axios 响应返回 200,而我的标题与我期望的页面中的不同。相反,我得到了
{ 'content-type': 'text/html;charset=utf-8',
server: 'Apache/2.4.39 (Amazon) Communique/4.2.2',
'last-modified': 'Thu, 12 Mar 2020 00:37:41 GMT',
etag: 'W/"785b9-5a09d8f80f9a5-gzip"',
'cache-control': 'max-age=217372',
expires: 'Thu, 19 Mar 2020 00:37:37 GMT',
date: 'Mon, 16 Mar 2020 12:14:45 GMT',
'transfer-encoding': 'chunked',
connection: 'close, Transfer-Encoding',
'x-activision-regioncode': 'EN',
'x-activision-countrycode': 'GB',
'access-control-allow-credentials': 'true',
'access-control-allow-origin': 'https://profile.callofduty.com' }
有谁知道如何捕获我需要的 set-cookie 标头?
【问题讨论】:
标签: javascript node.js axios