fix too many accounts error because the worker was behind a Cloudflare call, add username change

This commit is contained in:
Devin Zuczek
2026-08-04 21:04:00 -04:00
parent f3e2ab422c
commit 1d08ed8296
7 changed files with 340 additions and 23 deletions
+16
View File
@@ -6,6 +6,22 @@ export default defineConfig({
cloudflareTest({
wrangler: { configPath: `${__dirname}/wrangler.jsonc` },
miniflare: {
// Stands in for the `auth` service binding wrangler.jsonc declares — the real
// worker isn't part of this project's test run, and without an override the
// runtime refuses to start ("no such service is defined"). It echoes the
// forwarded `cf-connecting-ip` back so a test can assert the browser's IP
// actually survives the hop (see src/upstream.ts `postAuthForm`); every other
// auth call in the tests fails before reaching it.
serviceBindings: {
AUTH: (request: Request) =>
new Response(
JSON.stringify({
error: 'invalid_grant',
error_description: request.headers.get('cf-connecting-ip') ?? 'no ip',
}),
{ status: 400, headers: { 'content-type': 'application/json' } }
),
},
bindings: {
ENVIRONMENT: 'VITEST',
// The Turnstile keypair is NOT bound here: both keys come from the Secrets