Skip to content

fix: resolve image demo /api/image 500 on Vercel#253

Merged
ctate merged 1 commit intovercel-labs:mainfrom
vzt7:fix/image-demo-500-font-tracing
Apr 7, 2026
Merged

fix: resolve image demo /api/image 500 on Vercel#253
ctate merged 1 commit intovercel-labs:mainfrom
vzt7:fix/image-demo-500-font-tracing

Conversation

@vzt7
Copy link
Copy Markdown
Contributor

@vzt7 vzt7 commented Mar 31, 2026

Summary

image

The /api/image endpoint returns 500 on image-demo.json-render.dev.

Root cause

The image API uses Satori + resvg to render JSON specs into PNG. Satori requires font data passed as an ArrayBuffer, which the route loads via fs.readFile from:

process.cwd() + /node_modules/geist/dist/fonts/geist-sans/Geist-Regular.ttf

In a pnpm monorepo, node_modules/geist is a symlink pointing to the real location inside node_modules/.pnpm/geist@.../. Next.js file tracing (nft) traces the real path in the .pnpm store, but when Vercel assembles the serverless function it copies only the real file — the symlink at node_modules/geist/... does not exist in the function filesystem. So readFile throws ENOENT and the unhandled error surfaces as a 500.

Fix

Added outputFileTracingIncludes in next.config.ts to explicitly include the font file at the symlink path, ensuring it is present where the code expects it.

Test plan

  • Local build + next start/api/image returns 200 with valid PNG

Add outputFileTracingIncludes so the Geist font TTF is bundled at the
symlink path the code reads from. In a pnpm monorepo the file was only
traced at the .pnpm store path, which Vercel does not map back to the
node_modules/geist/ symlink.
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 31, 2026

@vzt7 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@ctate
Copy link
Copy Markdown
Collaborator

ctate commented Apr 7, 2026

@vzt7 Thanks for the contribution and the thorough root cause analysis!

@ctate ctate merged commit a123f56 into vercel-labs:main Apr 7, 2026
6 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants