824 B
824 B
using proxy with fetch https://www.zenrows.com/blog/node-fetch-proxy#how-to-use-proxy-with-node-fetch for username and password https://github.com/TooTallNate/proxy-agents/issues/12
const fetch = require('node-fetch');
const proxyUrl = 'http://proxyserver:port';
const proxyOptions = {
proxy: proxyUrl,
headers: {
'Proxy-Authorization': 'Basic ' + Buffer.from('username:password').toString('base64')
}
};
fetch('http://url-to-fetch', proxyOptions)
.then(response => response.text())
.then(data => {
console.log(data);
})
.catch(error => {
console.error('Error:', error);
});
Same with curl
curl -x http://proxyserver:port --proxy-user username:password http://url-to-fetch
for socks5
curl -v --socks5 127.0.0.1:1080 https://icanhazip.com
replace with socks4 for socks4