fix: Support runtime env var overrides via Nuxt runtimeConfig#589
Open
joris-sevenlab wants to merge 1 commit intonuxt-modules:mainfrom
Open
fix: Support runtime env var overrides via Nuxt runtimeConfig#589joris-sevenlab wants to merge 1 commit intonuxt-modules:mainfrom
joris-sevenlab wants to merge 1 commit intonuxt-modules:mainfrom
Conversation
|
@joris-sevenlab is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
commit: |
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
6ab9597 to
7f58791
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Types of changes
Description
The module reads
SUPABASE_URL/SUPABASE_KEYfromprocess.envin thedefaultsblock, but this only runs at build time. Afternuxt build, the values are baked in and can't be changed. So if you setNUXT_PUBLIC_SUPABASE_URLat runtime (e.g. in Docker or CI), it never actually gets picked up. On top of that, the module warns about missing config even whenNUXT_PUBLIC_*vars are set, because Nuxt applies those after module setup has already run.This replaces the
as stringcasts with|| undefinedso missing env vars don't end up as empty strings that blockdefumerges fromnuxt.config.ts. Also removes the manualNUXT_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: