Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



 2914

JavaScript API Question

by ConfigShop - 26 January, 2023 - 04:14 AM
This post is by a banned member (ConfigShop) - Unhide
123
Posts
23
Threads
3 Years of service
#1
So Iv been thinking about converting my openbullet configs into a JavaScript api so for example domain.com/config/whatever_config but can’t figure out how proxies would be able to pass through it as most proxy providers my customers use are ip bounded so how would my customers be able to run the config through for example proxiware on my api.
 
This post is by a banned member (Milky) - Unhide
Milky  
Supreme
160
Posts
26
Threads
5 Years of service
#2
(This post was last modified: 03 February, 2023 - 08:01 PM by Milky. Edited 1 time in total.)
(26 January, 2023 - 04:14 AM)ConfigShop Wrote: Show More
So Iv been thinking about converting my openbullet configs into a JavaScript api so for example domain.com/config/whatever_config but can’t figure out how proxies would be able to pass through it as most proxy providers my customers use are ip bounded so how would my customers be able to run the config through for example proxiware on my api.
As you explore the idea of converting your OpenBullet configs into a JavaScript API, you might be considering how to accommodate the use of proxies by your customers. Given that most proxy providers have IP-bound services, you might be wondering how to enable your API to run through such proxies.
Here's what you need to know: for your customers to use a proxy with your API, they must specify the proxy in the API request. With JavaScript and other programming languages, there are libraries available that enable you to specify a proxy in HTTP requests. This means that when the API request is made, it will pass through the specified proxy.
 It's crucial to keep in mind that if your API is IP-bound and your customers use a proxy, the IP address of the request will be that of the proxy, not the customer. This could present issues if your API only accepts requests from specific IP addresses. In this scenario, you must update your API to accept requests from the IP addresses of your customers' proxy providers.
 
Code:
 
const axios = require('axios');

async function runConfig(configName, proxy) {
  try {
    const response = await axios.get(`https://your-api-domain.com/config/${configName}`, {
      proxy: {
        host: proxy.host,
        port: proxy.port
      }
    });
    return response.data;
  } catch (error) {
    console.error(error);
    return error;
  }
}

const proxy = {
  host: 'proxy-host-name',
  port: 8080
};

runConfig('whatever_config', proxy)
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.error(error);
  });
This post is by a banned member (ConfigShop) - Unhide
123
Posts
23
Threads
3 Years of service
#3
(03 February, 2023 - 07:59 PM)Milky Wrote: Show More
(26 January, 2023 - 04:14 AM)ConfigShop Wrote: Show More
So Iv been thinking about converting my openbullet configs into a JavaScript api so for example domain.com/config/whatever_config but can’t figure out how proxies would be able to pass through it as most proxy providers my customers use are ip bounded so how would my customers be able to run the config through for example proxiware on my api.
As you explore the idea of converting your OpenBullet configs into a JavaScript API, you might be considering how to accommodate the use of proxies by your customers. Given that most proxy providers have IP-bound services, you might be wondering how to enable your API to run through such proxies.
Here's what you need to know: for your customers to use a proxy with your API, they must specify the proxy in the API request. With JavaScript and other programming languages, there are libraries available that enable you to specify a proxy in HTTP requests. This means that when the API request is made, it will pass through the specified proxy.
 It's crucial to keep in mind that if your API is IP-bound and your customers use a proxy, the IP address of the request will be that of the proxy, not the customer. This could present issues if your API only accepts requests from specific IP addresses. In this scenario, you must update your API to accept requests from the IP addresses of your customers' proxy providers.
 
Code:
 
const axios = require('axios');

async function runConfig(configName, proxy) {
  try {
    const response = await axios.get(`https://your-api-domain.com/config/${configName}`, {
      proxy: {
        host: proxy.host,
        port: proxy.port
      }
    });
    return response.data;
  } catch (error) {
    console.error(error);
    return error;
  }
}

const proxy = {
  host: 'proxy-host-name',
  port: 8080
};

runConfig('whatever_config', proxy)
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.error(error);
  });

Thank you your a legend
 

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 2 Guest(s)