Closed Nathan-Bernardo closed 6 months ago
Tried your code with latest version, and it's working fine for me:
env variable substitution for fileLoader
was implemented in v2.9.0, please reinstall the dependencies and try again.
I have the same problem. My yml
is:
app:
port: 3006
db:
dbHost: ${DB_HOST:'localhost'}
And my ConfigModule looks like:
export const ConfigModule = TypedConfigModule.forRoot({
schema: Config,
load: fileLoader({ disallowUndefinedEnvironmentVariables: true }),
});
I was expecting at least throwing an error, because DB_HOST
is not set or value should default to localhost
. But got this returned:
Config {
app: AppConfig { port: 3006 },
db: DbConfig {
dbHost: "${DB_HOST:'localhost'}",
}
Using the latest version 2.9.2
.
@taRusty see the test files for substitution reference, it's the same with dotenv-expand and not relevant with this issue. CodeSandbox link: https://codesandbox.io/p/devbox/brave-chatelet-jfd7zl?file=%2Fsrc%2Fconfig.ts%3A25%2C1
Oh, I had the wrong configuration then. It should be "${DB_HOST:-localhost}" instead
"${DB_HOST:'localhost'}". And then, I was also missing ignoreEnvironmentVariableSubstitution: false
. Didn't know the default is true
. My bad and apologies for this. Thank you for your help.
I'm submitting a...
Current behavior
Environment variable substitution defined in .env doesn't seem to be substituted into .env.yaml even when
ignoreEnvironmentVariableSubstitution: false
for file loader. Config file is defined belowThe current output is
Expected behavior
Expected output
Minimal reproduction of the problem with instructions
https://gist.github.com/Nathan-Bernardo/bcb98b2215571223299209b9088489f2
Environment