Skip to content

fix: Support runtime env var overrides via Nuxt runtimeConfig#589

Open
joris-sevenlab wants to merge 1 commit intonuxt-modules:mainfrom
joris-sevenlab:fix/nuxt-runtime-config-env-vars
Open

fix: Support runtime env var overrides via Nuxt runtimeConfig#589
joris-sevenlab wants to merge 1 commit intonuxt-modules:mainfrom
joris-sevenlab:fix/nuxt-runtime-config-env-vars

Conversation

@joris-sevenlab
Copy link

Types of changes

  • Bug fix (a non breaking change which fixes an issue)

Description

The module reads SUPABASE_URL / SUPABASE_KEY from process.env in the defaults block, but this only runs at build time. After nuxt build, the values are baked in and can't be changed. So if you set NUXT_PUBLIC_SUPABASE_URL at runtime (e.g. in Docker or CI), it never actually gets picked up. On top of that, the module warns about missing config even when NUXT_PUBLIC_* vars are set, because Nuxt applies those after module setup has already run.

This replaces the as string casts with || undefined so missing env vars don't end up as empty strings that block defu merges from nuxt.config.ts. Also removes the manual NUXT_PUBLIC_* reads from defaults since Nuxt already handles that through runtimeConfig. Production builds now only fail on actually invalid URLs, not missing ones, since those can still be provided at runtime.

Docs updated to mention the NUXT_PUBLIC_* / NUXT_* env var names for runtime use.

Fixes #470
Related: #587

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes (env var resolution and warning messages, no new testable behavior)

@vercel
Copy link

vercel bot commented Mar 18, 2026

@joris-sevenlab is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@joris-sevenlab joris-sevenlab changed the title Support runtime env var overrides via Nuxt runtimeConfig fix: Support runtime env var overrides via Nuxt runtimeConfig Mar 18, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 18, 2026

npm i https://pkg.pr.new/@nuxtjs/supabase@589

commit: 7f58791

  The module only read SUPABASE_URL/SUPABASE_KEY from process.env at build
  time. After `nuxt build`, values were baked in and could not be overridden
  at runtime via NUXT_PUBLIC_SUPABASE_* env variables. The module also
  warned incorrectly about missing config when using NUXT_PUBLIC_* vars.

  - Use `|| undefined` instead of `as string` so empty/missing env vars
    don't block defu merges with nuxt.config.ts values
  - Remove redundant manual NUXT_PUBLIC_* reads from defaults, Nuxt
    handles this natively via runtimeConfig at runtime
  - Only fail production builds on invalid URLs, not missing ones
  - Update docs to document runtime env var names

  Fixes nuxt-modules#470
  Related: nuxt-modules#587
@joris-sevenlab joris-sevenlab force-pushed the fix/nuxt-runtime-config-env-vars branch from 6ab9597 to 7f58791 Compare March 18, 2026 11:17
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.

Errant warnings when configuring with NUXT_PUBLIC_SUPABASE_KEY and NUXT_PUBLIC_SUPABASE_URL

1 participant