Force IPv4 for CARD API requests

card.charter.com resolves to both IPv4 (47.43.51.7) and IPv6
(2600:6c7f:9340:ca5::7). IPv6 is unreachable from this network,
causing Node.js to attempt IPv6 first, wait for timeout, then
fall back — but the 15s request timeout fires before the fallback
completes. Adding family: 4 to both acquireToken and doRequest
forces IPv4 resolution, matching curl behavior.
This commit is contained in:
Jordan Ramos
2026-05-27 18:06:07 -06:00
parent 43e10b8c06
commit 18a377aea2

View File

@@ -57,6 +57,7 @@ function acquireToken(timeout) {
port: fullUrl.port || (isHttps ? 443 : 80), port: fullUrl.port || (isHttps ? 443 : 80),
path: fullUrl.pathname + fullUrl.search, path: fullUrl.pathname + fullUrl.search,
method: 'POST', method: 'POST',
family: 4, // Force IPv4 — IPv6 is unreachable from this network
headers: { headers: {
'accept': 'application/json', 'accept': 'application/json',
'authorization': 'Basic ' + authString, 'authorization': 'Basic ' + authString,
@@ -150,6 +151,7 @@ async function cardRequest(method, urlPath, body, options) {
port: fullUrl.port || (isHttps ? 443 : 80), port: fullUrl.port || (isHttps ? 443 : 80),
path: fullUrl.pathname + fullUrl.search, path: fullUrl.pathname + fullUrl.search,
method, method,
family: 4, // Force IPv4 — IPv6 is unreachable from this network
headers, headers,
timeout, timeout,
}; };