node-zwave-js icon indicating copy to clipboard operation
node-zwave-js copied to clipboard

Add proxy support for outbound HTTP(S) requests

Open AlCalzone opened this issue 1 month ago • 1 comments

Discussed in https://github.com/zwave-js/zwave-js/discussions/8445

Originally posted by l3s2d November 21, 2025

Description

Currently outbound HTTP(S) requests made by zwave-js, don't respect HTTP_PROXY and HTTPS_PROXY.

I'm running zwave-js-ui in docker with the HTTP_PROXY and HTTPS_PROXY envvars set to a Squid instance. Checking for OTA Updates (getAvailableFirmwareUpdates) does not use the proxy. I verified by checking the Squid logs and also by blocking egress traffic outside of Squid.

Do you have a solution in mind?

I'm not familiar with zwave-js' codebase, but I suspect the library it uses for outbound requests supports using a proxy.

Describe alternatives you've considered

No response

Additional context

No response

AlCalzone avatar Nov 25 '25 14:11 AlCalzone

We need to add undici for this, so ky can use it:

Using EnvHttpProxyAgent to automatically read proxy settings from environment variables:

import ky from 'ky';
import {EnvHttpProxyAgent} from 'undici';

const proxyAgent = new EnvHttpProxyAgent();

const api = ky.extend({
	// @ts-expect-error - dispatcher is not in the type definition, but it's passed through to fetch.
	dispatcher: proxyAgent
});

const response = await api('https://example.com').json();

AlCalzone avatar Nov 25 '25 14:11 AlCalzone