Fix HTTPFacilitatorClient not following 308 redirects#1813
Merged
phdargen merged 3 commits intocoinbase:mainfrom Mar 30, 2026
Merged
Fix HTTPFacilitatorClient not following 308 redirects#1813phdargen merged 3 commits intocoinbase:mainfrom
phdargen merged 3 commits intocoinbase:mainfrom
Conversation
✅ Heimdall Review Status
|
|
@ayushozha is attempting to deploy a commit to the Coinbase Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Thanks for the fix @ayushozha, looks good! Please verify your commit and fix the formatting/lint issue |
The x402.org/facilitator/supported endpoint returns HTTP 308 before resolving to 200. HTTPFacilitatorClient did not normalize the base URL or explicitly request redirect following, causing syncFacilitatorOnStart to silently fail in some runtimes. When no supported payment kinds are loaded, the middleware passes all requests through as 200 instead of 402. - Strip trailing slashes from facilitator URL in constructor to prevent unnecessary 308 redirects from trailing-slash normalization - Explicitly set redirect: "follow" on all fetch calls (verify, settle, getSupported) for cross-runtime compatibility - Add tests for URL normalization and redirect option propagation Closes coinbase#1692
3bce7fb to
6064faf
Compare
phdargen
approved these changes
Mar 30, 2026
Contributor
Author
|
Thanks @phdargen! If there are any major tasks or issues you'd like to assign me, I'm totally open to contributing more. |
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
Fixes #1692
The
x402.org/facilitator/supportedendpoint returns HTTP 308 before resolving to 200.HTTPFacilitatorClientdid not normalize the base URL or explicitly request redirect following, causingsyncFacilitatorOnStartto silently fail in some JS runtimes. When no supported payment kinds are loaded, the middleware passes all requests through as 200 instead of returning 402.Root cause
While the Fetch API default
redirectmode is"follow", not all JS runtimes (Node.js versions, edge runtimes, polyfills) handle 308 redirects consistently — especially for POST requests where method preservation is required by spec but not always implemented.Changes
typescript/packages/core/src/http/httpFacilitatorClient.tsredirect: "follow"to all fetch callstypescript/packages/core/test/unit/http/httpFacilitatorClient.test.tstypescript/.changeset/fix-facilitator-redirect.mdTest plan
redirect: "follow"passed ongetSupported(),verify(),settle()cc @CarsonRoscoe @andichen0420