mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-24 07:28:11 +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"] ?? [];
|
const files = fields["images"] ?? [];
|
||||||
let imageUrls: string[] = [];
|
let imageUrls: string[] = [];
|
||||||
|
|
||||||
|
const host = process.env.INTERNAL_APP_URL
|
||||||
|
|| (req.protocol + "://" + req.get("host"));
|
||||||
|
|
||||||
const existing = req.body.existingImageUrls;
|
const existing = req.body.existingImageUrls;
|
||||||
if (existing) {
|
if (existing) {
|
||||||
if (Array.isArray(existing)) imageUrls.push(...existing);
|
const toAbsolute = (url: string) => url.startsWith('/') ? `${host}${url}` : url;
|
||||||
else imageUrls.push(existing);
|
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) {
|
if (files && files.length > 0) {
|
||||||
imageUrls.push(...files.map(f => `${host}/uploads/temp/${path.basename(f.path)}`));
|
imageUrls.push(...files.map(f => `${host}/uploads/temp/${path.basename(f.path)}`));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user