mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-15 19:52:54 -06:00

In some tests made on the testProxy function, the `new ProxyAgent()` was not working, even adding it the IP result was the same. I've change it to the `new HttpsProxyAgent()` and it worked. Refactored the proxy agent to center the same function/creation the same where it is used
18 lines
503 B
TypeScript
18 lines
503 B
TypeScript
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
|
|
import { wa } from '../whatsapp/types/wa.types';
|
|
|
|
export function makeProxyAgent(proxy: wa.Proxy | string) {
|
|
if (typeof proxy === 'string') {
|
|
return new HttpsProxyAgent(proxy);
|
|
}
|
|
|
|
const { host, password, port, protocol, username } = proxy;
|
|
let proxyUrl = `${protocol}://${host}:${port}`;
|
|
|
|
if (username && password) {
|
|
proxyUrl = `${protocol}://${username}:${password}@${host}:${port}`;
|
|
}
|
|
return new HttpsProxyAgent(proxyUrl);
|
|
}
|