In my script, I intend to proxy my requests using hide.me.
When I try replicating the post request using axios, it redirects me to the home page, instead of the required page.
Also tried using python requests, and it works just fine. Node-fetch and axios-http fail.
My current code is below:
const qs = require('qs');
const axios = require('axios');
const proxySiteMap = async () => {
let proxy_locations = ["de", "nl", "fi"]
let url = process.env.PRODUCT_SITEMAP_URL;
let proxy_host = process.env.PROXY_URI
let loc = randomChoice(proxy_locations);
let proxy_url = `https://${loc}.${proxy_host}`
console.log(proxy_url);
let config = {
url: proxy_url,
method: "POST",
headers: {
'authority': `${loc}.hideproxy.me`,
'origin': 'https://hide.me',
'content-type': 'application/x-www-form-urlencoded',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36',
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'referer': 'https://hide.me/',
'accept-language': 'en-US,en;q=0.9,sv;q=0.8,hy;q=0.7',
},
params: {
action: 'update'
},
data: qs.stringify({
u: url,
})
};
let html;
let response;
let links = [];
try{
response = await axios(config);
html = response.data;
console.log(response.config)
} catch(error){
console.log(`Error while fetching sitemap. Response code ${error}`)
}
Relatively new to javascript/nodejs don’t know what I’m doing wrong