Skip to content

Bug: Wrong env var label in middleware client — error message blames URL when anon key is missing #29

@mahdirajaee

Description

@mahdirajaee

Description

In src/libs/supabase/supabase-middleware-client.ts, the getEnvVar() call for the anon key passes the wrong label:

getEnvVar(process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY, 'NEXT_PUBLIC_SUPABASE_URL'),

The second argument should be 'NEXT_PUBLIC_SUPABASE_ANON_KEY', not 'NEXT_PUBLIC_SUPABASE_URL'.

Impact

If NEXT_PUBLIC_SUPABASE_ANON_KEY is not set, the thrown error says:

Reference to undefined env var: NEXT_PUBLIC_SUPABASE_URL

This sends developers debugging the wrong variable. Especially confusing since NEXT_PUBLIC_SUPABASE_URL might already be correctly set.

Fix

getEnvVar(process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY, 'NEXT_PUBLIC_SUPABASE_ANON_KEY'),

One-line change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions