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

    Class AuthError

    Thrown when authentication or authorization fails.

    Carries an HTTP status code suitable for returning directly in a response (typically 401 for invalid credentials, 500 for server-side auth failures).

    import { AuthError, createSupabaseContext } from '@supabase/server'

    const { data: ctx, error } = await createSupabaseContext(request, { allow: 'user' })
    if (error) {
    // error is an AuthError
    return Response.json(
    { message: error.message, code: error.code },
    { status: error.status },
    )
    }

    Hierarchy

    • Error
      • AuthError
    Index

    Constructors

    Properties

    Constructors

    • Parameters

      • message: string
      • code: string = AuthGenericError
      • status: number = 401

      Returns AuthError

    Properties

    status: number

    HTTP status code.

    • 401 — Invalid or missing credentials
    • 500 — Server-side auth failure (e.g., missing JWKS, env misconfiguration)
    code: string

    Machine-readable error code.