You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that the configuration of nitro's nitro.config.ts will eventually be serialized and read as JSON.
This creates the following problems:
When using Docker for image packaging, sensitive information must be configured in the code (such as database account passwords and some cloud service keys, etc.)
It is not possible to distinguish the configuration well for dev/test/prod, etc.
Expected goals
For example, when configuring the value of nitro.config.ts, we are allowed to configure environment variables, which will not be serialized and will only be read from the environment variables when the app starts.
Simple example:
exportdefaultdefineNitroConfig({compatibilityDate: "2025-01-11",storage: {cache: {driver: "redis",host: process.env.REDIS_HOST,// or env("REDIS_HOST")port: 6379,},},
Additional information
Would you be willing to help implement this feature?
The text was updated successfully, but these errors were encountered:
@pqnet
This is relevant to be able to use the database effectively in production, as the password is rarely hardcodable in nitro.config file
This is very common, for example, it can be perfectly solved #1161 (comment)
It is worth mentioning that, for example, SvelteKit's solution is to type the KV of .env and then export it from $env.private.
The reason I like Nitro/Nuxt is the typing of runtimeConfig, which allows TS to detect the configuration I am using.
There are also some other problems that need this kind of situation, such as:
I have a CORS middleware that has different configurations for different environments.
Solve the configuration of Storage and DB in different environments
There is also the most important problem: Nitro uses c12 for serialization configuration, but there is a serious problem. The configuration method of $env.<name> is supported in the configuration file. But I had to implement the NODE_ENV setting at the stage of building the program, which resulted in the built program not being able to be directly deployed to the corresponding environment, and could only be built for NODE_ENV
Not everyone uses platforms such as Vercel/Netifty/cloudflare for deployment
For example, I use docker and use actions to automatically deploy and build, so my configuration must be like this:
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
RUN bun run build
Describe the feature
I noticed that the configuration of nitro's nitro.config.ts will eventually be serialized and read as JSON.
This creates the following problems:
When using Docker for image packaging, sensitive information must be configured in the code (such as database account passwords and some cloud service keys, etc.)
It is not possible to distinguish the configuration well for dev/test/prod, etc.
Expected goals
For example, when configuring the value of
nitro.config.ts
, we are allowed to configure environment variables, which will not be serialized and will only be read from the environment variables when the app starts.Simple example:
Additional information
The text was updated successfully, but these errors were encountered: