Skip to content

fix(auth): let clients sign in with a client metadata document on Workers - #62

Merged
donnes merged 1 commit into
mainfrom
t3/fix-cimd-fetch-workers
Dec 2, 2026
Merged

donnes merged 1 commit into
mainfrom
t3/fix-cimd-fetch-workers

Conversation

@donnes

@donnes donnes commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

After #61, Executor's Spendle sign-in got past discovery but stopped at /api/auth/oauth2/authorize with invalid_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's Request throws on that value, so on Workers every metadata-document client failed before any request went out. The Workers transport in src/platform/cloudflare/auth.server.ts now builds the request with redirect: 'manual'. A redirect is still not followed: it comes back as a 3xx that CIMD refuses.

Testing

  • Proof: in the local Workers runtime (vp build --mode qa, vp preview --mode qa), the authorize request Executor sends returned exactly this invalid_client error before the change; after it, the same request continues to /autorizar.
  • A metadata URL that redirects (https://httpbin.org/redirect/1) is refused with Metadata document fetch returned HTTP 302.
  • Web typecheck, lint and format pass.

Created with Claude Opus 5.5 in Claude Code (T3 Code).

…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>
@donnes
donnes merged commit f1db207 into main Dec 2, 2026
2 checks passed
@donnes
donnes deleted the t3/fix-cimd-fetch-workers branch December 2, 2026 14:41
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.

1 participant