mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
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:
1 parent
281597e944
commit
abaee384bf
1 file changed
+6
-4
@@ -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)}`));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user