我的密码是
const axios = require('axios')
const https = require('https');
const axiosCookieJarSupport = require("axios-cookiejar-support");
const tough = require("tough-cookie");
const HEADERS = {
'Content-Type': 'application/json; odata.streaming=true; charset=utf-8',
Accept: 'application/json; odata.metadata=none, text/plain',
'TM1-SessionContext': '----',
'User-Agent': '----'
}
this.http = axios.create({
headers: HEADERS,
withCredentials: true,
httpsAgent: new https.Agent({ rejectUnauthorized: false })
})
axiosCookieJarSupport.wrapper(this.http)
this.http.defaults.jar = new tough.CookieJar()
this.http.defaults.baseURL = this.baseUrl
// Then other things but that doesn't matter
但是当我运行时,我得到了这个错误:
Error: axios-cookiejar-support does not support for use with other http(s).Agent.
at requestInterceptor (C:\node_modules\axios-cookiejar-support\dist\index.js:14:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RestService.startSession (C:\main.js:109:29)
我猜问题出在用https. Agent({})初始化的https代理上
可能存在相同的构造函数从axios库,但我没有找到它
先谢谢你
1条答案
按热度按时间qxgroojn1#
https://github.com/3846masa/axios-cookiejar-support/issues/426和https://github.com/3846masa/axios-cookiejar-support/issues/431可以回答类似的问题
简而言之,您希望使用自定义HTTPS代理
httpsAgent: new https.Agent({ rejectUnauthorized: false })
,但axios-cookiejar-support
无法与之配合使用。尝试使用
http-cookie-agent
代替axios-cookiejar-support
,如下所示: