Skip to content

feat: add route-specific OpenGraph & Twitter preview cards (issue #124) - #131

Open
reddyharsha11 wants to merge 6 commits into
useagenthq:mainfrom
reddyharsha11:issue-124-preview-card
Open

reddyharsha11 wants to merge 6 commits into
useagenthq:mainfrom
reddyharsha11:issue-124-preview-card

Conversation

@reddyharsha11

@reddyharsha11 reddyharsha11 commented Oct 12, 2026 •

Copy link
Copy Markdown

Summary

Resolves issue #124. Adds dynamic and route-specific OpenGraph and Twitter cards across all major routes of the application using existing static preview images in public/og/.

Key Changes

  1. Dynamic Origin Resolution (app/layout.tsx):

    • Replaced static metadata export with generateMetadata() that dynamically resolves x-forwarded-proto and x-forwarded-host so image URLs point to the active host (localhost, tunnel, or production domain).
  2. Route-Specific Page Metadata:

    • Updated metadata across all core routes (/dashboard, /bots, /apps, /settings, /wiki, /skills, /tasks, /knowledge, /memory, etc.) to specify their distinct openGraph and twitter titles, descriptions, and static PNG assets from public/og/.
  3. Proxy Crawler Support (proxy.ts):

    • When link preview bots and social crawlers (Facebook, Twitter/X, WhatsApp, Telegram, Discord, Slack, OpenGraph inspectors) request protected routes without a session cookie, the proxy serves the exact HTML OpenGraph tags for that route instead of redirecting them to /login.
    • Regular human browsers without a session continue to be redirected to /login.
  4. Security & Proxy Whitelisting:

    • Kept /og/* static assets whitelisted so crawlers and clients can fetch preview images without requiring session cookies.

Verification

  • Tested and verified live on OpenGraph.xyz with 10/10 checks passing.
  • Verified route-specific cards for /dashboard (04-dashboard.png), /bots (05-agents.png), and /login (01-home.png).
  • Automated tests passing: 14/14 tests in bun test app/metadata.test.ts proxy.test.ts.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

- Add metadataBase, openGraph, and twitter metadata to root layout.tsx
- Add dynamic login metadata with ref=hacktoberfest description
- Add app/opengraph-image.tsx serving 01-home.png (1600x900)
- Add app/twitter-image.tsx re-exporting the same image
- Add page-specific og:image for bots (05-agents.png) and settings (08-customize.png)
- Allow /opengraph-image and /twitter-image through auth proxy without session
- Add 18 feature mockup PNGs to public/og/ for future per-route assignment
- Add metadata.test.ts (3 tests) covering root layout, image specs, and hacktoberfest
- Update proxy.test.ts with og-image route coverage
- All 14 tests pass, tsc and biome clean
…genthq#124)

- Add app/og-helper.ts: shared utility (ogImageResponse, ogSize, ogContentType)
  to avoid boilerplate duplication across route-level image files

- Add per-route opengraph-image.tsx for:
    /bots              -> 05-agents.png
    /dashboard         -> 04-dashboard.png
    /settings          -> 08-customize.png
    /apps              -> 07-apps.png
    /knowledge         -> 11-knowledge.png
    /memory            -> 12-memory.png
    /playbooks         -> 13-playbooks.png
    /review            -> 14-reviews.png
    /skills            -> 15-skills.png
    /learnings         -> 17-learnings.png
    /wiki              -> 18-wiki.png

- proxy.ts: change exact /opengraph-image match to endsWith() so all
  per-route OG image paths pass through the auth middleware without a
  session cookie (link preview crawlers have no cookie)

- proxy.test.ts: add /bots/opengraph-image, /settings/opengraph-image,
  /bots/twitter-image to the allow list assertions

- next.config.ts: add *.loca.lt to allowedDevOrigins for local testing
  with localtunnel

All 14 tests pass. tsc and biome clean.
- layout.tsx: replace static metadata export with generateMetadata()
  that reads x-forwarded-host/host headers at runtime, so og:image URL
  resolves correctly on localhost, localtunnel, and production without
  any hardcoded domain

- login/page.tsx: add explicit og:image + twitter:image using the same
  dynamic host resolution (needed because the [[...login]] catch-all
  segment prevents co-locating an opengraph-image.tsx sibling)

- metadata.test.ts: mock next/headers, switch to calling generateMetadata()
  instead of reading static metadata export

All 14 tests pass.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 10:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants