Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/pages/_api/api/openapi.json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { generate } from "mppx/discovery";
import { mppx } from "../../../mppx.server";

const USDC = "0x20c000000000000000000000b9537d11c60e8b50";

export function GET() {
const doc = generate(mppx, {
info: { title: "mpp.dev", version: "1.0.0" },
routes: [
{
handler: mppx.charge({
amount: "0.1",
currency: USDC,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use configured currency in OpenAPI discovery

The discovery document advertises payment metadata from a hardcoded USDC address here, but the actual /api/ping/paid endpoint charges import.meta.env.VITE_DEFAULT_CURRENCY in src/pages/_api/api/ping/paid.ts. In any deployment where that env var differs (the repository’s .env.example already uses a different address), /openapi.json will publish incorrect x-payment-info, causing clients that rely on discovery to pay with the wrong token and fail when they hit the real Challenge flow.

Useful? React with 👍 / 👎.

description: "Ping endpoint access",
}),
method: "get",
path: "/api/ping/paid",
summary: "Paid ping — returns a greeting after payment",
},
],
serviceInfo: {
categories: ["web"],
docs: {
homepage: "https://mpp.dev",
llms: "https://mpp.dev/llms.txt",
},
},
});

return Response.json(doc, {
headers: {
"Access-Control-Allow-Origin": "*",
"Cache-Control": "public, max-age=3600",
},
});
}
6 changes: 6 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"rewrites": [
{
"source": "/openapi.json",
"destination": "/api/openapi.json"
}
],
"redirects": [
{
"source": "/:path(.*)",
Expand Down
Loading