Skip to content

Revalidate server pages after registration + display dynamic pricing#921

Merged
onchainlu merged 2 commits into
mainfrom
fix-display-bugs
May 22, 2026
Merged

Revalidate server pages after registration + display dynamic pricing#921
onchainlu merged 2 commits into
mainfrom
fix-display-bugs

Conversation

@onchainlu
Copy link
Copy Markdown
Contributor

@onchainlu onchainlu commented May 22, 2026

Summary

Two fixes for server page display issues:

1. Revalidate server pages after registration

  • Server pages (/server/[id]) were serving stale data because Next.js cached the SSR output
  • Added revalidatePath calls after successful registration in all four registration paths (tRPC register, tRPC registerFromOrigin, REST register, REST register-origin)
  • Pages remain statically cached for fast loads — only invalidated when data actually changes

2. Display dynamic pricing from discovery metadata

  • Endpoints with dynamic pricing (e.g. stableflowers /api/orders) showed "$300.00" instead of "Up to $300.00"
  • Root cause: the 402 probe has no body, so the router falls back to maxPrice with scheme: exact. The discovery doc correctly says pricingMode: "dynamic" but this was discarded during registration
  • Fix: extract pricingMode from the discovery document, store it in Resources.metadata, and use it in ResourcePricing to detect dynamic pricing regardless of the 402 scheme
  • Falls back gracefully for old resources and single-endpoint registrations (no discovery doc)

Test plan

  • Deploy to Vercel preview
  • Re-register stableflowers.dev → server page should show "Up to $300.00" for POST /api/orders
  • Check stablevoice.dev → paid resources should still show exact prices, SIWX should show "Free"
  • Register a new origin → resource count should update immediately on server page
  • Click refresh button on server page → should still work (no regression)

Server pages were serving stale data (resource counts, pricing) because
Next.js cached the SSR output. Now all four registration paths call
revalidatePath to bust the cache for the affected origin's server page.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
x402scan Ready Ready Preview, Comment May 22, 2026 2:26pm

Request Review

@onchainlu onchainlu merged commit 10fd80f into main May 22, 2026
3 checks passed
@onchainlu onchainlu changed the title Revalidate server pages after resource registration Revalidate server pages after registration + display dynamic pricing May 22, 2026
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.

1 participant