@supabase/server - v0.2.0
    Preparing search index...

    Interface WithSupabaseConfig

    Configuration for withSupabase and createSupabaseContext.

    Controls which auth modes are accepted, environment overrides, and CORS behavior.

    // Require authenticated users, auto-CORS enabled (default)
    const config: WithSupabaseConfig = { allow: 'user' }

    // Accept users or service-to-service calls, custom CORS headers
    const config: WithSupabaseConfig = {
    allow: ['user', 'secret'],
    cors: { 'Access-Control-Allow-Origin': 'https://myapp.com' },
    }

    // No auth required, CORS disabled
    const config: WithSupabaseConfig = { allow: 'always', cors: false }
    interface WithSupabaseConfig {
        allow?: AllowWithKey | AllowWithKey[];
        env?: Partial<SupabaseEnv>;
        cors?: boolean | Record<string, string>;
        supabaseOptions?: SupabaseClientOptions<string>;
    }
    Index

    Properties

    Auth mode(s) to accept. Modes are tried in order — the first match wins. A mode falls through only when its credential is absent; a present-but-invalid JWT short-circuits the chain with InvalidCredentialsError.

    "user"

    env?: Partial<SupabaseEnv>

    Override auto-detected environment variables. Useful for testing or when running in environments without standard env var support.

    cors?: boolean | Record<string, string>

    CORS configuration for the withSupabase wrapper.

    • true (default) — uses @supabase/supabase-js default CORS headers.
    • false — disables CORS handling entirely.
    • Record<string, string> — custom CORS headers.

    Only applies to the top-level withSupabase wrapper. The Hono adapter handles CORS separately via Hono's own middleware.

    true

    supabaseOptions?: SupabaseClientOptions<string>

    Options forwarded to both internal createClient() calls.

    accessToken is stripped, and auth settings (persistSession, autoRefreshToken, detectSessionInUrl) are force-overwritten to server-safe values.

    withSupabase({
    allow: 'user',
    supabaseOptions: { db: { schema: 'api' } },
    }, handler)