test(supabase): avatar e2e clients refuse HTTP redirects

The suite's supabase-js clients followed redirects by default, so a 3xx
from the sandbox gateway would have carried the apikey header to another
origin. `noRedirectFetch` (`redirect: 'error'`) is passed as `global.fetch`
of both client factories; a regression test with two loopback servers
proves REST, auth and Storage calls stop at the 302. Live proof j and a
second 5/5 run are in the audit log; no production client changes.
This commit is contained in:
bchanot committed 2026-11-02 11:22:51 +01:00
1 parent e8da0d96d9
commit d3dfd03213
7 files changed
+147 -16

No files matched your search

@@ -15,6 +15,7 @@ import { createHash, randomBytes } from 'node:crypto'
import { execFileSync } from 'node:child_process'
import { deflateSync } from 'node:zlib'
import { createClient, type SupabaseClient } from '@supabase/supabase-js'
import { noRedirectFetch } from './noRedirectFetch'
import {
beginAvatarUpload,
confirmAssetUpload,
@@ -52,6 +53,7 @@ type Client = SupabaseClient<Database>
function anonClient(): Client {
return createClient<Database>(SANDBOX_URL, ANON ?? '', {
auth: { persistSession: false, autoRefreshToken: false },
global: { fetch: noRedirectFetch },
})
}
@@ -65,6 +67,7 @@ async function signedIn(email: string): Promise<Client> {
function serviceClient(): Client {
return createClient<Database>(SANDBOX_URL, SERVICE ?? '', {
auth: { persistSession: false, autoRefreshToken: false },
global: { fetch: noRedirectFetch },
})
}