Skip to content

fix: use validated env in createAdminClient instead of raw process.env#7

Open
Sertug17 wants to merge 1 commit into
circlefin:masterfrom
Sertug17:fix/admin-env-validation
Open

fix: use validated env in createAdminClient instead of raw process.env#7
Sertug17 wants to merge 1 commit into
circlefin:masterfrom
Sertug17:fix/admin-env-validation

Conversation

@Sertug17

Copy link
Copy Markdown

createAdminClient was reading NEXT_PUBLIC_SUPABASE_URL directly from process.env with a non-null assertion, bypassing the Zod validation in serverEnv/clientEnv. If the env var is missing at runtime, the error would be a cryptic cannot-read-property-of-undefined instead of the structured validation from the schema.

Also switched to clientEnv.NEXT_PUBLIC_SUPABASE_URL since this is a public (NEXT_PUBLIC_) variable that's validated in clientSchema.

createAdminClient was reading NEXT_PUBLIC_SUPABASE_URL directly from
process.env with a non-null assertion, bypassing the Zod validation
in serverEnv/clientEnv. If the env var is missing at runtime, the
error would be a cryptic cannot-read-property-of-undefined instead
of the structured validation error from the schema.

Also switched to clientEnv.NEXT_PUBLIC_SUPABASE_URL since this is a
public (NEXT_PUBLIC_) variable validated in clientSchema.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant