From abaee384bf27feb2a57eb0c89ff48f536094b09c Mon Sep 17 00:00:00 2001 From: Michael SCHAL Date: Wed, 25 Mar 2026 11:00:30 +0100 Subject: [PATCH] fix: resolve relative media URLs to absolute before passing to Remotion renderer Remotion's headless Chromium cannot load relative /uploads/... paths. Library images were passed as-is, causing "Error loading image" at render time. Now resolves them using INTERNAL_APP_URL (Docker) or the request host (dev). Co-Authored-By: Claude Sonnet 4.6 --- server/routes/remotion.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/routes/remotion.ts b/server/routes/remotion.ts index daccc40..a32cc06 100644 --- a/server/routes/remotion.ts +++ b/server/routes/remotion.ts @@ -93,13 +93,15 @@ remotionRouter.post("/render", upload.fields([{ name: "images", maxCount: 4 }, { const files = fields["images"] ?? []; let imageUrls: string[] = []; + const host = process.env.INTERNAL_APP_URL + || (req.protocol + "://" + req.get("host")); + const existing = req.body.existingImageUrls; if (existing) { - if (Array.isArray(existing)) imageUrls.push(...existing); - else imageUrls.push(existing); + const toAbsolute = (url: string) => url.startsWith('/') ? `${host}${url}` : url; + if (Array.isArray(existing)) imageUrls.push(...existing.map(toAbsolute)); + else imageUrls.push(toAbsolute(existing)); } - - const host = req.protocol + "://" + req.get("host"); if (files && files.length > 0) { imageUrls.push(...files.map(f => `${host}/uploads/temp/${path.basename(f.path)}`)); }