Skip to content

Conversation

@edevil
Copy link

@edevil edevil commented Nov 26, 2025

Description

A transparent proxy template with payment-gated routes using the x402 protocol and stateless JWT cookie authentication. Includes built-in test endpoints for health checks and payment flow demonstration.

Checklist

  • Template Metadata
    • template directory ends with -template
    • "cloudflare" section of package.json is populated
    • template preview image uploaded to Images
    • README is populated and uses <!-- dash-content-start --> and <!-- dash-content-end --> to designate the Dash readme preview
    • .gitignore file exists
    • package.json contains a deploy command
    • package.json contains private: true and no version field

Example package.json

"private": true,
"cloudflare": {
  "label": "Worker + D1 Database",
  "products": [
    "Workers",
    "D1"
  ],
  "categories": [
    "storage"
  ],
  "docs_url": "https://developers.cloudflare.com/d1/",
  "preview_image_url": "https://imagedelivery.net/wSMYJvS3Xw-n339CbDyDIA/cb7cb0a9-6102-4822-633c-b76b7bb25900/public"
}

@edevil edevil force-pushed the x402proxy branch 7 times, most recently from 11d91cb to 2bdd43a Compare November 27, 2025 12:37
@github-actions
Copy link
Contributor

template name version latestVersion isDevDependency
x402-proxy-template @coinbase/x402 ^0.7.1 0.7.3 false
x402-proxy-template hono ^4.10.4 4.10.7 false
x402-proxy-template x402-hono ^0.7.1 0.7.3 false
x402-proxy-template @typescript-eslint/eslint-plugin ^8.46.4 8.48.0 true
x402-proxy-template @typescript-eslint/parser ^8.46.4 8.48.0 true
x402-proxy-template eslint ^9.39.1 9.39.1 true
x402-proxy-template eslint-config-prettier ^10.1.8 10.1.8 true
x402-proxy-template prettier ^3.6.2 3.7.1 true
x402-proxy-template tsx ^4.20.6 4.20.6 true
x402-proxy-template viem ^2.38.6 2.40.3 true
x402-proxy-template wrangler ^4.46.0 4.51.0 true
x402-proxy-template x402 ^0.7.1 0.7.3 true

@github-actions
Copy link
Contributor

Preview link not generated: you must be on a branch, not on a fork.
Collaborators may enable previews for this pull request by attaching the allow preview label.
If you are already a collaborator, please create a branch rather than forking.

1 similar comment
@github-actions
Copy link
Contributor

Preview link not generated: you must be on a branch, not on a fork.
Collaborators may enable previews for this pull request by attaching the allow preview label.
If you are already a collaborator, please create a branch rather than forking.

Copy link
Contributor

@deloreyj deloreyj left a comment

Choose a reason for hiding this comment

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

One change on the tests and an image, and we should be good to go!

@@ -0,0 +1,72 @@
import { test, expect } from "./fixtures";

test.describe("x402 Payment-Gated Proxy Template", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The playwright tests are primarily meant to be a minimal smoke test to ensure the templates run after maintenance like dependency updates. With that in mind, I'm hesitant to test the full API in this spec file since it requires an actual wallet address. Could you keep the health endpoint tests here and move the others into a test file within the template itself?

Copy link
Author

Choose a reason for hiding this comment

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

We don't actually test the full api, we stop before making the payment. So, there is no wallet requirement.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do the playwright tests run for you locally? When I try to run them I get 500s for the protected endpoints with this error

✘ [ERROR] InvalidAddressError: Address "0xYOUR_WALLET_ADDRESS_HERE" is invalid.


  - Address must be a hex value of 20 bytes (40 hex characters).
  - Address must match its checksum counterpart.

  Version: [email protected]
      at getAddress (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/viem/utils/address/getAddress.ts:79:11)
      at paymentMiddleware2 (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected]_@[email protected][email protected]_typescri_551d0b8b9e34c36381373de6d91ed451/node_modules/x402-hono/src/index.ts:141:16)
      at null.<anonymous> (file:///Users/jdelorey/code/templates/x402-proxy-template/src/auth.ts:48:16)
      at null.<anonymous> (file:///Users/jdelorey/code/templates/x402-proxy-template/src/auth.ts:95:48)
      at null.<anonymous> (file:///Users/jdelorey/code/templates/x402-proxy-template/src/index.ts:77:24)
      at dispatch (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected]/node_modules/hono/dist/compose.js:22:23)
      at null.<anonymous> (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected]/node_modules/hono/dist/compose.js:5:12)
      at null.<anonymous> (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected]/node_modules/hono/dist/hono-base.js:201:31)
      at #dispatch (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected]/node_modules/hono/dist/hono-base.js:211:5)
      at Hono2.fetch (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected]/node_modules/hono/dist/hono-base.js:214:17) {
    details: undefined,
    docsPath: undefined,
    metaMessages: [
      '- Address must be a hex value of 20 bytes (40 hex characters).',
      '- Address must match its checksum counterpart.'
    ],
    shortMessage: 'Address "0xYOUR_WALLET_ADDRESS_HERE" is invalid.',
    version: '2.40.3'
  }


[wrangler:info] GET /__x402/protected 500 Internal Server Error (59ms)

Copy link
Author

Choose a reason for hiding this comment

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

My bad, I had some local changes that made the test pass. I've replaced the default wallet with the usual dummy address that is still valid.

Didn't you run into the missing JWT_SECRET issue or did you remember to copy the .dev.vars.example file?

@edevil edevil force-pushed the x402proxy branch 2 times, most recently from c54b721 to 0c4ad15 Compare December 2, 2025 22:33
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

template name version latestVersion isDevDependency
x402-proxy-template @coinbase/x402 ^0.7.1 0.7.3 false
x402-proxy-template hono ^4.10.4 4.10.7 false
x402-proxy-template x402-hono ^0.7.1 0.7.3 false
x402-proxy-template @typescript-eslint/eslint-plugin ^8.46.4 8.48.1 true
x402-proxy-template @typescript-eslint/parser ^8.46.4 8.48.1 true
x402-proxy-template eslint ^9.39.1 9.39.1 true
x402-proxy-template eslint-config-prettier ^10.1.8 10.1.8 true
x402-proxy-template prettier ^3.6.2 3.7.3 true
x402-proxy-template tsx ^4.20.6 4.21.0 true
x402-proxy-template viem ^2.38.6 2.40.4 true
x402-proxy-template wrangler ^4.46.0 4.51.0 true
x402-proxy-template x402 ^0.7.1 0.7.3 true

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

Preview link not generated: you must be on a branch, not on a fork.
Collaborators may enable previews for this pull request by attaching the allow preview label.
If you are already a collaborator, please create a branch rather than forking.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

template name version latestVersion isDevDependency
x402-proxy-template @coinbase/x402 ^0.7.1 0.7.3 false
x402-proxy-template hono ^4.10.4 4.10.7 false
x402-proxy-template x402-hono ^0.7.1 0.7.3 false
x402-proxy-template @typescript-eslint/eslint-plugin ^8.46.4 8.48.1 true
x402-proxy-template @typescript-eslint/parser ^8.46.4 8.48.1 true
x402-proxy-template eslint ^9.39.1 9.39.1 true
x402-proxy-template eslint-config-prettier ^10.1.8 10.1.8 true
x402-proxy-template prettier ^3.6.2 3.7.4 true
x402-proxy-template tsx ^4.20.6 4.21.0 true
x402-proxy-template viem ^2.38.6 2.41.2 true
x402-proxy-template wrangler ^4.46.0 4.52.1 true
x402-proxy-template x402 ^0.7.1 0.7.3 true

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

Preview link not generated: you must be on a branch, not on a fork.
Collaborators may enable previews for this pull request by attaching the allow preview label.
If you are already a collaborator, please create a branch rather than forking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants