From a4ec44c163b7bf7733adb28387844e8fb29ebd53 Mon Sep 17 00:00:00 2001 From: mgraf158 <40839831+mgraf158@users.noreply.github.com> Date: Wed, 28 Jan 2026 12:34:41 +0100 Subject: [PATCH] feat: automatically use EnvHttpProxyAgent for proxy support This patch makes pino-loki automatically detect proxy settings from the environment (HTTP_PROXY / HTTPS_PROXY / NO_PROXY) using undici's EnvHttpProxyAgent. This ensures that logs are correctly sent in corporate network environments without requiring manual dispatcher injection. --- src/log_pusher.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/log_pusher.ts b/src/log_pusher.ts index f61a877..0588d5f 100644 --- a/src/log_pusher.ts +++ b/src/log_pusher.ts @@ -1,6 +1,7 @@ import debug from './debug.ts' import { LogBuilder } from './log_builder.ts' import type { PinoLog, LokiOptions } from './types.ts' +import { Dispatcher, EnvHttpProxyAgent } from "undici"; class RequestError extends Error { responseBody: string @@ -18,9 +19,11 @@ class RequestError extends Error { export class LogPusher { #options: LokiOptions #logBuilder: LogBuilder + #agent: Dispatcher constructor(options: LokiOptions) { this.#options = options + this.#agent = new EnvHttpProxyAgent() // for automatic HTTP-proxy support this.#logBuilder = new LogBuilder({ levelMap: options.levelMap, @@ -83,6 +86,7 @@ export class LogPusher { 'Content-Type': 'application/json', }, body: JSON.stringify({ streams: lokiLogs }), + dispatcher: this.#agent, }, )