utils/proxy.js
A module for ac-bundle-app, published by ac-bundle-module.
Available Methods: httpAgent, httpsAgent, fetch
httpAgent
function createHttpProxyAgent(opts) {
return new agent_1.default(opts);
}
httpsAgent
function createHttpsProxyAgent(opts) {
return new agent_1.default(opts);
}
fetch
async function(proxyUrl, url, method, data, headers) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
if (!app.has(headers)) headers = {};
if (!app.has(method)) method = "GET";
var agent = new mod.httpsAgent(proxyUrl);
if (config.api.log.url) console.log("VIA PROXY: " + proxyUrl + " > " + url + " " + method);
if (!url.toLowerCase().split("http://").shift()) agent = mod.httpAgent(proxyUrl);
var options = {
method: method,
agent: agent,
headers: headers
};
if (app.has(data)) options.body = JSON.stringify(data);
return await fetch(url, options);
}
Happy Coding!