Created
October 18, 2021 17:43
-
-
Save SanariSan/c58123ca003ed87965d3928a191f85c6 to your computer and use it in GitHub Desktop.
Axios proxy http/s socks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// socks | |
// const axios_ = require("axios"); | |
// const SocksProxyAgent = require("socks-proxy-agent"); | |
import { default as axios_ } from "axios"; | |
import SocksProxyAgent from "socks-proxy-agent"; | |
const httpsAgent = new SocksProxyAgent("socks://127.0.0.1:1080"); | |
const httpAgent = httpsAgent; | |
const axios = axios_.create({ httpsAgent, httpAgent }); | |
axios({ method: "GET", url: "https://json.myip.wtf" }).then(console.log).catch(console.log); | |
// ------- | |
// http/s | |
// const axios = require("axios"); | |
import axios from "axios"; | |
axios({ method: "GET", url: "https://json.myip.wtf", proxy: { | |
protocol: "https", | |
host: "127.0.0.1", | |
port: 1090, | |
auth: { username: "name", password: "pass" }, | |
}, | |
}) | |
.then(console.log) | |
.catch(console.log); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment