Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support updateRuntimeConfig() to update global runtime config #2427

Open
pi0 opened this issue May 9, 2024 · 0 comments
Open

Support updateRuntimeConfig() to update global runtime config #2427

pi0 opened this issue May 9, 2024 · 0 comments
Labels
discussion enhancement New feature or request

Comments

@pi0
Copy link
Member

pi0 commented May 9, 2024

Context: #2404 (comment)

Sometimes it is useful to update runtime config in server runtime using name. Currently, it is only possible by mapping environment variables with the same (and known names)

Example:

// server/plugins/runtime-config.ts

export default defineNitroPlugin(() => {
 const configOverrides = { foo: { bar: "baz" } }; // load from any source
 updateRuntimeConfig(configOverrides);
 // any code in any file after this line will be affected
})

Discussion:

We should choose between two orders: (low to high):

  1. bundled vars > programmatic overrides > environment variable
  2. bundled vars > environment variable > programmatic overrides

2 makes sense in the way that manual updateRuntimeConfig is more explicit than implicit environment variables (more making sense in testing scenarios) but it also breaks 12 factor and can cause headaches for sys admins not being able to quickly control instance behavior.

I am thinking of using order 1 but allowing a way to opt out from the environment variable support (testing environments in case there is a chance of conflict)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant