mejorar lógica de ignorar tls

This commit is contained in:
Cat /dev/Nulo 2023-12-29 12:23:34 -03:00
parent 8c06f68484
commit 1f07c48cac

View file

@ -7,7 +7,13 @@ const dispatcher = new Agent({
maxRedirections: 20, maxRedirections: 20,
}); });
const ignoreTlsDispatcher = new Agent({ const ignoreTlsDispatcher = new Agent({
connect: { timeout: 60 * 1000, rejectUnauthorized: false }, connect: {
timeout: 60 * 1000,
rejectUnauthorized: false,
checkServerIdentity() {
return undefined;
},
},
bodyTimeout: 15 * 60 * 1000, bodyTimeout: 15 * 60 * 1000,
maxRedirections: 20, maxRedirections: 20,
}); });
@ -87,7 +93,11 @@ function getHeaders(url) {
*/ */
export async function customRequest(url) { export async function customRequest(url) {
let d = dispatcher; let d = dispatcher;
if (url.hostname === "datos.agroindustria.gob.ar") { if (
url.hostname === "www.energia.gob.ar" ||
url.hostname === "datos.agroindustria.gob.ar" ||
url.hostname === "www.agroindustria.gob.ar"
) {
d = ignoreTlsDispatcher; d = ignoreTlsDispatcher;
} }
const res = await request(url.toString(), { const res = await request(url.toString(), {