diff --git a/dist/webhooks/post.js b/dist/webhooks/post.js index f0a49fe..20c1920 100644 --- a/dist/webhooks/post.js +++ b/dist/webhooks/post.js @@ -24,7 +24,9 @@ function guardedLookup(allowPrivate) { } if (opts["all"]) return callback(null, usable); - const first = usable[0]; + // One address wanted (Node 18 has no happy-eyeballs fallback): prefer IPv4, as Node did before v17, + // so "localhost" reaches a receiver bound to 127.0.0.1 instead of failing on ::1. + const first = (usable.find((a) => a.family === 4) ?? usable[0]); return callback(null, first.address, first.family); }); }); diff --git a/src/webhooks/post.ts b/src/webhooks/post.ts index 03b5e71..54e62b8 100644 --- a/src/webhooks/post.ts +++ b/src/webhooks/post.ts @@ -45,7 +45,9 @@ function guardedLookup(allowPrivate: boolean): LookupFunction { return callback(new BlockedAddressError(`${hostname} resolves only to non-public addresses`)); } if (opts["all"]) return callback(null, usable); - const first = usable[0] as LookupAddress; + // One address wanted (Node 18 has no happy-eyeballs fallback): prefer IPv4, as Node did before v17, + // so "localhost" reaches a receiver bound to 127.0.0.1 instead of failing on ::1. + const first = (usable.find((a) => a.family === 4) ?? usable[0]) as LookupAddress; return callback(null, first.address, first.family); }); }) as LookupFunction;