Add x402 CORS preflight handling#9
Open
elianguitarra wants to merge 1 commit into
Open
Conversation
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.
/claim #6
Payout if accepted: Base USDC
0x237664403f52A15142795f807ADB3524E8057909.Summary
This handles the browser/agent cutover gap discussed on issue #6 and PR #5: x402-related endpoints currently return
405 method not allowedto browser preflight requests, which blocks cross-origin browser agents or marketplace clients before they can read the 402/payment metadata.Changes:
204forOPTIONSon:/api/payment-request/api/protected-resource/api/x402-verify-receiptx-payment,x-awm-signature,x-awm-timestamp, etc.)Link,x-ai-work-market-payment-required,x-payment-response, etc.)Verification
Ran with the bundled Node runtime available in this environment:
node --check api/_cors.jsnode --check api/payment-request.jsnode --check api/protected-resource.jsnode --check api/x402-verify-receipt.jsnode --check scripts/test-x402-receipt-verifier.jscors helper checks passedgit diff --checkI could not run the full existing
scripts/test-x402-receipt-verifier.jslocally in this fresh clone becausenode_modulesis not installed and this Windows runtime has Node but no npm on PATH; the script importsethers. I added the preflight coverage to that suite so it can run in the normal project environment/CI after dependencies are installed.Scope note
This does not loosen fulfillment checks, receipt verification, HMAC, finality, or consumption behavior. It only makes the public payment/verifier endpoints reachable by browser-style clients that perform CORS preflight.