0

I want to create a custom proxy server with no specific target and request through that proxy using axios in a separate project. Not as url proxy(i Don't actually know what are they called) where request url needs to be like this: "proxyserverurl/targeturl" Instead i need to use this as a proxy which needs to be provided as proxy object in axios with port and host.

I've tried many node-modules and various suggestions of internet to create the server. Like this one here: https://stackoverflow.com/a/63602976 I'm using replit to create the server. And it gives me a url like this: https://replname.username.repl.co

But the problem is i can't make request through this server. I tried something like this.

const axios = require('axios');

const axiosInstance = axios.create({
  proxy: {
    host: 'replname.username.repl.co',
    port: 3000
  }
});

console.log('Sending request...');

axiosInstance.get('https://www.google.com')
  .then(response => {
    console.log('Response:', response.data);
  })
  .catch(error => {
    console.error('Error:', error);
  })
  .finally(() => {
    console.log('Request complete.');
  });

But it just logs sending request then nothing logs neither on proxy server or this project console. Not even errors. What am i doing wrong? What can i do to achieve what I'm seeking? (Sorry for bad explaining)

0 Answers0