有哪个网站可以学做早餐吃的,我的世界做图片的网站,wordpress网站云备份,大网站开发在使用 axios 库的时候#xff0c;希望用 burp 抓包查看发包内容。但关于 axios 设置代理问题#xff0c;网上提到的一些方法不是好用#xff0c;摸索了一段时间后总结出设置 burp 代理抓包的方法。
nodejs 中 axios 设置 burp 抓包
根据请求的站点#xff0c;分为 http …在使用 axios 库的时候希望用 burp 抓包查看发包内容。但关于 axios 设置代理问题网上提到的一些方法不是好用摸索了一段时间后总结出设置 burp 代理抓包的方法。
nodejs 中 axios 设置 burp 抓包
根据请求的站点分为 http 和 https 两个类型。
http
只需要添加 proxy
// http 测试网站 http://www.5icool.org/import https from https;
import axios from axios;const proxy {protocol: http, // 这里设置协议为 httphost: 127.0.0.1,port: 8080
}async function test() {const res await axios.post(http://www.5icool.org/, {title: foo,body: bar,userId: 1,}, {proxy: proxy // http 站点就直接设置 proxy 参数headers: {Content-type: application/json; charsetUTF-8},})console.log(res.data)}await test();
https
要添加 proxy 以及 httpsAgent
// https 测试站点 https://jsonplaceholder.typicode.com/postsimport https from https;
import axios from axios;
let httpsAgent new https.Agent({rejectUnauthorized: false, // 因为是 https over http 所以需要设置 rejectUnauthorized 为 false
});
const proxy {protocol: https, // 这里要设置 https host: 127.0.0.1,port: 8080
}async function test() {const res await axios.post(https://jsonplaceholder.typicode.com/posts, {title: foo,body: bar,userId: 1,}, {httpsAgent: httpsAgent, // 添加 httpsAgentproxy: proxy, // 添加 proxyheaders: {Content-type: application/json; charsetUTF-8},})console.log(res.data)}await test();