Skip to content

Link previews drop description + image (embeds/metadata reads non-existent result.metadata.* from Trek) #758

@hellno

Description

@hellno

Summary

app/api/embeds/metadata/route.ts reads Trek's parse output via result.metadata.*, but @officialunofficial/trek@0.2.1 flattens metadata onto the result rootresult.metadata is undefined. So when Trek (the primary parser) returns a title, the route emits a preview with title only — no description, no image — and returns early, never reaching the Microlink/Neynar fallbacks that would have supplied them.

Repro (verified against the live page)

GET /api/embeds/metadata?url=https://jup.ag/prediction/world-cup

The page's server HTML contains:

  • og:image = https://jup.ag/meta-og/jupiter-meta-prediction-world-cup-v2.webp
  • og:description = "Pick 5 World Cup matches. Win all 5 to share the prize pool."

Trek extracts them correctly (top level): result.image = "…world-cup-v2.webp", result.description = "…".
But the route reads result.metadata.og_image / .descriptionundefined, so the API returns { metadata: { url, title: "Jupiter" } } — no image, no description.

In-app this renders as a link card with a title but no thumbnail and no description (e.g. the jup.ag/prediction/world-cup embed).

Root cause

// route.ts (fetchWithTrek)
const metadata = result.metadata || {};                              // result.metadata is undefined → {}
const title = metadata.title || metadata.og_title || result.title;   // survives via result.title fallback
// ...
description: metadata.description || metadata.og_description,         // → undefined
image: metadata.og_image || metadata.image,                          // → undefined

Trek 0.2.1 returns result.title / result.description / result.image / result.favicon at the root; there is no result.metadata.

Fix

Read the top-level fields:

const title = result.title;
const description = result.description;
const image = result.image;
const favicon = result.favicon || new URL('/favicon.ico', url).href;

Impact

Every link preview where Trek finds a title (the common case) shows title only — most visibly, no preview image.

Notes

  • Found during the TanStack Start spike ([Epic] Migrate Next.js 15 → TanStack Start (SSR) on Cloudflare Workers #754) while porting this route; independent of the migration.
  • Verified empirically by running @officialunofficial/trek@0.2.1 on the live page (Node, prod-style readFileSync + initSync).
  • Caveat to confirm: if the .wasm doesn't actually load in the Vercel bundle, the route falls through to Microlink/Neynar and the bug is masked (but Trek would then be dead weight). Worth confirming which case is live.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions