Repository navigation
Revert "docs(x402): deprecate x402 integration" - #2017
Conversation
This reverts commit a68736f.
|
| const paidUrl = "http://localhost:5173/protected-route"; | ||
| const res = await this.fetchWithPay(paidUrl, {}); |
There was a problem hiding this comment.
🟡 Payments demo only works on a local machine and fails once deployed
The paid endpoint is requested at a fixed local development address (http://localhost:5173/protected-route at examples/x402/src/server.ts:41) instead of the address the app is actually running on, so the demo's "Fetch & Pay" button fails whenever the example is deployed.
Impact: Anyone who deploys this example to Cloudflare gets an error instead of the paid response.
Hardcoded dev origin in the agent's outbound fetch
PayAgent.fetchProtectedRoute (examples/x402/src/server.ts:33-49) builds paidUrl from a literal http://localhost:5173, which is only valid under vite dev. The example's deploy script (examples/x402/package.json:8) builds and deploys to Workers, where that origin is unreachable from the Durable Object, so this.fetchWithPay(paidUrl, {}) rejects and the UI shows a connection error. The agent has no access to the incoming request origin here, so the origin should be derived from configuration (e.g. an env var or a value passed from the callable) rather than hardcoded.
Prompt for agents
In examples/x402/src/server.ts, PayAgent.fetchProtectedRoute hardcodes http://localhost:5173/protected-route. This only works under `vite dev`; after `npm run deploy` the Durable Object cannot reach that origin and the demo fails. Consider passing the page origin from the client through the @callable method, or reading a configured base URL from env (with the localhost value only as a local default), and document it in the README.
Was this helpful? React with 👍 or 👎 to provide feedback.
agents
@cloudflare/ai-chat
@cloudflare/codemode
create-think
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
Reverts #2000.
This restores the x402 integration, examples, tests, and playground references removed by #2000.
Validation
pnpm install --frozen-lockfilepnpm run check