Serverless OG image renderer for social media link previews. Deploys as a Vercel function.
- Receives a
?u=query parameter with an encoded URL - Launches headless Chromium via Puppeteer and navigates to the URL
- Waits for the
#cardelement to appear - Screenshots the element and processes it with Sharp (resized to 1200×630px JPEG)
- Returns the image with aggressive cache headers
GET /render?u=<encoded-url>
Only URLs from brainrot.girard-davila.net are allowed (SSRF protection). All other origins return 403.
Response headers:
Cache-Control: public, max-age=86400, stale-while-revalidate=604800
- Node.js 22, TypeScript
@sparticuz/chromium— serverless-optimized Chromiumpuppeteer-core— headless browser controlsharp— image resizing and JPEG encoding- Vercel — serverless hosting
npm install
vercel dev
# → http://localhost:3000/render?u=<encoded-url>vercel deploy # preview
vercel deploy --prod # production