From 7e69f2b3f35fc3bc0bfd734565fe73fbcbed6640 Mon Sep 17 00:00:00 2001 From: Sven Date: Tue, 21 Apr 2026 23:29:33 +0200 Subject: [PATCH] fix: add cover-proxy internal URL rewrite patch for node jail isolation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Node jail has no outbound internet — cover-proxy must rewrite audio.giersig.eu/media/* fetches to http://10.100.0.10:8091/media/* using the new mediaInternalUrl config option. Co-Authored-By: Claude Sonnet 4.6 --- ...atch-listening-endpoint-runtime-guards.mjs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scripts/patch-listening-endpoint-runtime-guards.mjs b/scripts/patch-listening-endpoint-runtime-guards.mjs index 0f52c39b..bafb7ec6 100644 --- a/scripts/patch-listening-endpoint-runtime-guards.mjs +++ b/scripts/patch-listening-endpoint-runtime-guards.mjs @@ -778,6 +778,33 @@ const patchSpecs = [ "node_modules/@indiekit/indiekit/node_modules/@rmdes/indiekit-endpoint-funkwhale/index.js", ], }, + { + name: "funkwhale-cover-proxy-internal-url-rewrite", + marker: "Rewrite media URLs to internal endpoint when node jail can't reach public hostname", + oldSnippet: ` try { urlObj = new URL(rawUrl); } catch { return response.status(400).send("Invalid url"); } + try { + const upstream = await fetch(rawUrl, {`, + newSnippet: ` try { urlObj = new URL(rawUrl); } catch { return response.status(400).send("Invalid url"); } + + // Rewrite media URLs to internal endpoint when node jail can't reach public hostname + let fetchUrl = rawUrl; + const { funkwhaleConfig } = request.app.locals.application; + if (funkwhaleConfig?.mediaInternalUrl && funkwhaleConfig?.instanceUrl) { + try { + const instanceHost = new URL(funkwhaleConfig.instanceUrl).hostname; + if (urlObj.hostname === instanceHost) { + fetchUrl = funkwhaleConfig.mediaInternalUrl.replace(/\\/+$/, "") + urlObj.pathname + urlObj.search; + } + } catch {} + } + + try { + const upstream = await fetch(fetchUrl, {`, + candidates: [ + "node_modules/@rmdes/indiekit-endpoint-funkwhale/index.js", + "node_modules/@indiekit/indiekit/node_modules/@rmdes/indiekit-endpoint-funkwhale/index.js", + ], + }, ]; async function exists(filePath) {