Repository navigation
feat(lore-0042): run the example seller behind a tunnel, in an image - #254
Open
Bartek-str wants to merge 6 commits into
Open
Bartek-str wants to merge 6 commits into
Bartek-str wants to merge 6 commits into
Conversation
Behind the server's Cloudflare tunnel the request reaches the seller as plain http, so the 402 named an http:// resource. The catalog's check after a settle asks the seller at that URL through the seller-fetch guard, which refuses http (not_https), so no listing was written. PUBLIC_ORIGIN, optional, https and an origin only, makes the route name <origin>/weather. Unset, the seller behaves as before.
In a container Node is PID 1, which ignores a SIGTERM it does not handle, so every docker stop and deploy would wait out the grace period and kill it. The seller now stops taking requests, lets open ones finish and exits 0, as the facilitator and the portal do.
The seller is to run on the production server beside the facilitator, where everything runs in Docker. Same base and layout as the facilitator's and the portal's images; it holds no secret.
The Claude Desktop config named a placeholder catalog. Our facilitator serves the testnet catalog in public since 0032.
The four commits before this one, what was checked on them, and the e2e run on their code: 26 of 26 scenarios, three payments settled on testnet with their hashes. Ticks the README criterion.
karolko9
reviewed
Nov 25, 2026
karolko9
left a comment
Collaborator
There was a problem hiding this comment.
A few findings for consideration, read at ae513e66. Four reviews ran on it, the 23 tests pass, and nothing was tried behind the real tunnel. Your call on each.
- Could
app.set("trust proxy", true)replacePUBLIC_ORIGIN?@x402/expressbuilds the URL fromreq.protocoland Host (index.mjs:55), and cloudflared keeps both. That's about −45 lines and no setting to keep in step with the hostname. - If
PUBLIC_ORIGINstays:config.ts:31-38acceptshttps://user:pw@host,https://host.andhttps://127.0.0.1, which the catalog refuses later, so the seller is silently never listed. FACILITATOR_URLdefaults to x402.org (config.ts:15). If PR 2 forgets it, payments settle but never reach our catalog.- For PR 2: after the 16.12 reset the probe stays green while payments fail, because the 402 comes from config. Could it check that
payToexists and has its trustline? - For PR 2: junk payments copied from the public 402 cost nothing and share the server's single IP limit on
/verify, so ~600 of them make the seller look dead.
Correctness held: with PUBLIC_ORIGIN the listing passes validate, the seller check and sameListing, and unset nothing changes.
PUBLIC_ORIGIN accepted a user and password, a trailing dot, an IP address, a single label and private suffixes such as .local. The catalog refuses those hosts after a settle, so the seller ran but was silently never listed. It now stops at start instead, by the same rules packages/bazaar applies, copied so the example needs none of our packages.
Bartek-str
added a commit
that referenced
this pull request
Nov 26, 2026
The task stays active. Its seller code is in PR #254, under review.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First of two PRs for 0042, a seller that always answers in the testnet catalog for the Claude
Desktop run (D2). This one makes
examples/http-apiready to run behind the server's tunnel; thesecond brings its deploy files and its probe. The task stays active.
examples/http-api/src/config.ts,app.ts): optionalPUBLIC_ORIGIN, httpsand an origin only. Set, the 402 names
<origin>/weather. Behind the tunnel the seller sees plainhttp, so it named an
http://resource; the catalog's check after a settle asks the seller atthat URL through the seller-fetch guard, which refuses it (
not_https), and no listing waswritten. Unset, nothing changes.
examples/http-api/src/index.ts): the seller stops taking requests, lets open onesfinish and exits 0. In a container Node is PID 1 and ignores a SIGTERM it doesn't handle.
examples/http-api/Dockerfile): the facilitator's pinned base and layout; it holds nosecret.
apps/mcp-local/README.md): the Claude Desktop config names our catalog,https://x402-facilitator.sorobanscan.com, instead of a placeholder.lore/1-tasks/active/0042_…): what was checked and the e2e run's hashes; the READMEcriterion ticked.
Reviewers, please confirm:
PUBLIC_ORIGINpassesthe cataloger's validate, seller check and
sameListing), and thattestnet-results.jsonstaysas it was, since this run's commit field would name a commit without these changes.
this image; the deploy files come in the next PR for your review.
examples/http-apichanges here before 0102's PR 3 makes it use the SDK'sseller helpers;
createApptakespublicOriginandindex.tspasses the whole config.Please confirm
PUBLIC_ORIGINis https, an origin only, and a host a catalog lists (discovery, dev-tools):an http value would bring back the listing the catalog can't check, and a path would make the
route name a URL other than its own. A user or password, an IP address, a trailing dot, a single
label or a private suffix stop the start (
10650853, after review), by the rulespackages/bazaarapplies, copied so the example needs none of our packages. Without it the seller names the request's URL, as before, so local runs and the e2eare unchanged.
docker stopanddeploy would wait out the grace period and kill the seller; the facilitator and the portal
handle it the same way.
Testing
pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build→ all pass but@stellar-x402/deploytests on macOS:openbao-snapshot.test.tsandportal.test.tsfail withflock: command not found, the same two files ondevelopwithout these commits; CI's Linux hasflock.@stellar-x402/example-http-api→ 33 tests, new: the 402 behind a proxy names the public httpsresource and a paid request still settles;
PUBLIC_ORIGINrefused when http, a path, a query, or a host the catalog refuses (each checked againstpackages/bazaar's owncanonicalizeUrlandisPublicResourceUrl);SIGTERM exits 0.
pnpm mcp:e2eon the code of8dee9c1e→ 26 of 26 scenarios passed, three payments of0.001 USDC settled and
successfulon Horizon:263d5b00c6f7440b28d5c3228ea9441ac205ae3729f84c2f7248752f9e74d2ba(E-21),60a8ef6d533b1ae10599c1bbac63549c82dc9ce0734a712f09279a524e8e4d67(E-22),bdebcc1fe02fadf0226d821512ebb88904a6d4dda0a7fc8e15ae3128e7f280c0(E-25, search then pay). Itstarts the seller without
PUBLIC_ORIGIN, so it shows the payment path still works.packages/bazaar, ascataloger.tsruns them) fed the seller's real402 with
PUBLIC_ORIGIN=https://x402-seller.sorobanscan.com→ validated, check requestGET https://x402-seller.sorobanscan.com/weather?city=Warsaw, listing with ourpayToand10000,
sameListingtrue.--read-only --cap-drop ALL --security-opt no-new-privileges:trueagainst ourfacilitator → 402 naming
https://x402-seller.sorobanscan.com/weatheronstellar:testnet; aprobe from inside the container gets 402;
docker stopreturns at once, exit 0.deployed catalog, the Claude Desktop run.