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 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Sonnet 4.6 committed 2026-03-25 11:00:30 +01:00
1 parent 281597e944
commit abaee384bf
1 file changed
+6 -4
+6 -4
View File
@@ -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)}`));
}