Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

docs: improve runtimeConfig example #5785

Merged
merged 3 commits into from
Jul 13, 2022
Merged

docs: improve runtimeConfig example #5785

merged 3 commits into from
Jul 13, 2022

Conversation

duvior
Copy link
Contributor

@duvior duvior commented Jul 8, 2022

Made the nuxt.config.ts example using .env, a little more explicit.

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Made the nuxt.config.ts example using .env, a little more explicit.
@netlify
Copy link

netlify bot commented Jul 8, 2022

βœ… Deploy Preview for nuxt3-docs ready!

Name Link
πŸ”¨ Latest commit 7ad9f1f
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/62cec0233883a10008749eb0
😎 Deploy Preview https://deploy-preview-5785--nuxt3-docs.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@atinux atinux requested a review from danielroe July 11, 2022 11:37
Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work as written. The point being made above is:

For this to work, you must have a fallback value (which can just be an empty string) defined in your nuxt.config.

We're trying to avoid the situation where someone thinks that just because they have apiSecret: process.env.NUXT_API_SECRET defined in the config, that this will therefore means it gets overriden in production. (It won't work unless NUXT_API_SECRET is defined at build-time.

Instead, it must be at least: apiSecret: process.env.NUXT_API_SECRET || ''.

We also want to make it clear that the name of the environment variable is determined by the key within runtimeConfig - e.g. apiSecret becaomes NUXT_API_SECRET rather than by the environment variable passed as the default variable.

Any thoughts about how to make the above clearer in the example would be welcome.

@danielroe danielroe changed the title Improved the environment variables example docs: improve runtimeConfig example Jul 11, 2022
@danielroe danielroe added the documentation Improvements or additions to documentation label Jul 11, 2022
@pi0
Copy link
Member

pi0 commented Jul 11, 2022

Any thoughts about how to make the above clearer in the example would be welcome.

We might use comments in the docs after the value: (example)

var: '' // Can be overridden by NUXT_APP_VAR environment variable

Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go with @pi0's suggestion, which I think is clearer.

docs/content/2.guide/2.features/10.runtime-config.md Outdated Show resolved Hide resolved
docs/content/2.guide/2.features/10.runtime-config.md Outdated Show resolved Hide resolved
@pi0 pi0 merged commit a745be3 into nuxt:main Jul 13, 2022
@pi0 pi0 mentioned this pull request Jul 15, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants