我试图在axios中禁用角SSL验证。我试过用
axios.get(url, {
httpsAgent: new https.Agent({
rejectUnauthorized: false
})
})但是它显示一个错误Cannot find name 'https'.ts(2304)。所以我导入了https,然后它抛出了一个新的错误Module not found: Error: Can't resolve 'https'
是否有一种方法可以在axios角度上禁用SSL验证?
发布于 2020-03-31 13:51:52
您可以将axios配置为使用自定义代理:
实例
const instance = axios.create({
httpsAgent: new https.Agent({
rejectUnauthorized: false
})
});
instance.get('https://something.com/foo');请求
const request= new https.Agent({
rejectUnauthorized: false
});
axios.get('https://something.com/foo', { httpsAgent: request});希望这能有所帮助!
https://stackoverflow.com/questions/60952021
复制相似问题