Skip to content

fix(examples): run HTTP demos against local demo server - #689

Open
Kewe63 wants to merge 1 commit into
sapiom:mainfrom
Kewe63:fix-88-examples-demo-server
Open

fix(examples): run HTTP demos against local demo server#689
Kewe63 wants to merge 1 commit into
sapiom:mainfrom
Kewe63:fix-88-examples-demo-server

Conversation

@Kewe63

@Kewe63 Kewe63 commented Aug 23, 2026

Copy link
Copy Markdown

Summary

Fixes #88

The HTTP examples currently rely on https://x402-demo.sapiom.ai, but that public demo host can return Cloudflare 403s and make the examples fail before users can verify the SDK integration.

This PR makes the axios, fetch, and node-http examples self-contained by running them against a local demo server by default.


Changes

  • Add examples/local-demo-server.mjs with the endpoint shapes used by the HTTP examples:
    • GET /api/public/time
    • GET /api/public/status
    • GET /api/crm/customers
    • POST /api/sms
    • POST /api/campaigns/analytics
  • Add examples/run-local-demo.mjs to start the local server, set DUMMY_SERVER_URL=http://localhost:3101, run the selected example script, and shut the server down.
  • Update axios/fetch/node-http npm start, npm run free, and npm run full scripts to use the local demo helper.
  • Update .env.example and README docs so the broken public demo host is no longer the default.
  • Add troubleshooting guidance for x402-demo.sapiom.ai 403s.

How to Test

corepack pnpm examples:check:test
corepack pnpm examples:check
node --check examples/local-demo-server.mjs
node --check examples/run-local-demo.mjs
git diff --check

npm start     # examples/axios
npm start     # examples/fetch
npm start     # examples/node-http
npm run full  # examples/axios
npm run full  # examples/fetch
npm run full  # examples/node-http

✅ All passed locally.


Compatibility

  • No SDK API changes.
  • No dependency changes.
  • Example-only behavior change: HTTP examples now use a local demo server by default.
  • Users can still override DUMMY_SERVER_URL to point at another compatible server.

Checklist

  • Tests pass — all example scripts and validation checks green
  • Follows Conventional Commits
  • Changes scoped to this fix only
  • No SDK API or dependency changes

Risk & Impact

Low. Example-only change — no SDK code, API surface, or dependencies are touched. Users who already override DUMMY_SERVER_URL are unaffected; the change only alters the default target for the HTTP examples.

Type: 🐛 Bug fix
Fixes: #88

@github-actions github-actions Bot added contribution: incomplete Required pull request information is incomplete or ambiguous contributor: external Pull request author does not have write, maintain, or admin access to sapiom-js needs-triage Awaiting maintainer review and classification review: manual External pull request requires maintainer review before automation review: sensitive Changes affect sensitive repository or release infrastructure size: medium Review size is 101–500 changed lines area: examples-docs Changes to examples or public documentation labels Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: examples-docs Changes to examples or public documentation contribution: incomplete Required pull request information is incomplete or ambiguous contributor: external Pull request author does not have write, maintain, or admin access to sapiom-js needs-triage Awaiting maintainer review and classification review: manual External pull request requires maintainer review before automation review: sensitive Changes affect sensitive repository or release infrastructure size: medium Review size is 101–500 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

examples: x402-demo.sapiom.ai returns 403 — HTTP examples fail

1 participant