diff --git a/server/index.ts b/server/index.ts index a49e1598..e5306945 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1426,7 +1426,9 @@ async function process3DGenJob(job: Gen3DJob) { const MODEL = "fal-ai/hunyuan3d-v21"; try { - // 1. Resize staged image with sharp (max 1024px) for reliable fal.ai processing + // 1. Resize staged image with sharp (max 1024px) and inline as data URI so fal.ai + // never has to fetch from our origin (Cloudflare/Traefik/subdomain routing can + // intermittently block fal.ai's fetcher → "invalid images found in the input"). let imageInput = job.imageUrl; const stagedMatch = job.imageUrl.match(/\/(?:api\/files|data\/files)\/generated\/([^?#]+)/); if (stagedMatch) { @@ -1439,11 +1441,8 @@ async function process3DGenJob(job: Gen3DJob) { .resize(1024, 1024, { fit: "inside", withoutEnlargement: true }) .jpeg({ quality: 90 }) .toBuffer(); - const resizedName = `stage-resized-${Date.now()}-${Math.random().toString(36).slice(2, 6)}.jpg`; - await Bun.write(resolve(dir, resizedName), resizedBuf); - // Use public HTTPS URL for the resized image - imageInput = `${PUBLIC_ORIGIN}/api/files/generated/${resizedName}`; - console.log(`[3d-gen] Resized image: ${Math.round(resizedBuf.length / 1024)}KB → ${imageInput}`); + imageInput = `data:image/jpeg;base64,${resizedBuf.toString("base64")}`; + console.log(`[3d-gen] Inlined resized image: ${Math.round(resizedBuf.length / 1024)}KB (data URI)`); } } catch (e: any) { console.warn(`[3d-gen] Resize failed, using original URL:`, e.message);