From 8e41344c09035b7ef984da4871fa158d40cf42b7 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 30 May 2026 00:12:49 -0400 Subject: [PATCH] fix: Protocol error with http->https redirect --- server/utils/fetch.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/utils/fetch.ts b/server/utils/fetch.ts index c6fc3f95d2..a640af020c 100644 --- a/server/utils/fetch.ts +++ b/server/utils/fetch.ts @@ -167,7 +167,13 @@ export default async function fetch( ...rest, headers, signal, - agent: buildAgent(url, { signal, allowPrivateIPAddress }), + // Passed as a function rather than a static agent so that node-fetch + // re-selects the correct http/https agent for each request in a redirect + // chain. Otherwise an http:// URL redirecting to https:// (or vice versa) + // would reuse the original protocol's agent and throw + // `Protocol "https:" not supported. Expected "http:"`. + agent: (parsedURL) => + buildAgent(parsedURL.href, { signal, allowPrivateIPAddress }), }); if (!response.ok) {