Skip to content

Commit 6d5d376

Browse files
dcposchclaude
andcommitted
Reject non-402 responses: only proxy MPP-gated services
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 12f150b commit 6d5d376

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

src/index.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,12 @@ async function handleMppRequest(req: Request): Promise<Response> {
7171
...(input.body ? { body: JSON.stringify(input.body) } : {}),
7272
});
7373

74-
// 2. If not 402, return the response directly
74+
// 2. If not 402, this isn't an MPP-gated request
7575
if (targetRes.status !== 402) {
76-
let body: unknown;
77-
const ct = targetRes.headers.get("content-type") ?? "";
78-
if (ct.includes("json")) {
79-
body = await targetRes.json();
80-
} else {
81-
body = await targetRes.text();
82-
}
83-
return json({ status: "success", response: { status: targetRes.status, body } });
76+
return error(
77+
`${input.url} returned ${targetRes.status}, not 402. This endpoint does not require MPP payment. Call it directly instead.`,
78+
400
79+
);
8480
}
8581

8682
// 3. Parse and validate MPP 402 challenge (only charge intent supported)

0 commit comments

Comments
 (0)