Repository navigation
fix(auth): let clients sign in with a client metadata document on Workers - #62
Merged
Merged
Conversation
…kers Better Auth's CIMD fetch asks for `redirect: 'error'`, which workerd's Request rejects, so every metadata URL client (Executor) failed with invalid_client. The Workers transport now uses `manual`, which keeps redirects unfollowed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
After #61, Executor's Spendle sign-in got past discovery but stopped at
/api/auth/oauth2/authorizewithinvalid_client: Failed to fetch metadata document (network error or redirect blocked). Executor identifies itself with a Client ID Metadata Document (client_id=https://executor.sh/oauth/client-metadata.json), and that URL serves its JSON fine.Better Auth's CIMD plugin fetches the document with
redirect: 'error', and workerd'sRequestthrows on that value, so on Workers every metadata-document client failed before any request went out. The Workers transport insrc/platform/cloudflare/auth.server.tsnow builds the request withredirect: 'manual'. A redirect is still not followed: it comes back as a 3xx that CIMD refuses.Testing
vp build --mode qa,vp preview --mode qa), the authorize request Executor sends returned exactly thisinvalid_clienterror before the change; after it, the same request continues to/autorizar.https://httpbin.org/redirect/1) is refused withMetadata document fetch returned HTTP 302.Created with Claude Opus 5.5 in Claude Code (T3 Code).