Closed mschoeffmann closed 8 months ago
this appears to be working correctly @mschoeffmann. here's a test demonstrating it. https://github.com/motdotla/dotenv-expand/pull/121/files
what does your dotenv.config and dotenvExpand code look like? keep in mind we removed ignoreProcessEnv
and replaced it with processEnv
(https://github.com/motdotla/dotenv-expand/blob/master/CHANGELOG.md#removed). possibly are you using the processEnv
argument to dotenv.config ?
The variable DEVCONTAINER_CADDY_PUBLIC_DOMAIN
is set to mydom.test
in a Devcontariner's docker-compose file and is available.
My corresponding part of my app's config is:
console.log('BEFORE >>>'); // for demo
Object.entries(process.env).map((x) => x[0].indexOf('PUBLIC_') >= 0 && console.log(x)); // for demo
const devEnv = dotenv.config({ path: path.resolve(require.main.path, '../../.env') });
dotenvExpand.expand(devEnv);
console.log('AFTER >>>'); // for demo
Object.entries(process.env).map((x) => x[0].indexOf('PUBLIC_') >= 0 && console.log(x)); // for demo
The corrsponding .env entries:
PUBLIC_DOMAIN="${DEVCONTAINER_CADDY_PUBLIC_DOMAIN}"
PUBLIC_BASE_URL="https://${PUBLIC_DOMAIN}"
PUBLIC_API_BASE_URL="/api/v1"
Outputs:
BEFORE >>>
[ 'DEVCONTAINER_CADDY_PUBLIC_DOMAIN', 'mydom.test' ]
AFTER >>>
[ 'DEVCONTAINER_CADDY_PUBLIC_DOMAIN', 'mydom.test' ]
[ 'PUBLIC_DOMAIN', 'mydom.test' ]
[ 'PUBLIC_BASE_URL', 'https://${DEVCONTAINER_CADDY_PUBLIC_DOMAIN}' ]
[ 'PUBLIC_API_BASE_URL', '/api/v1' ]
So, sorry, it's not about the variable itself, it's about the double recursion: PUBLIC_BASE_URL < PUBLIC_DOMAIN < DEVCONTAINER_CADDY_PUBLIC_DOMAIN
confirmed issue here: https://github.com/motdotla/dotenv-expand/pull/121
sorry about this. working on patch.
that one was tricky to track down but is done now. https://github.com/motdotla/dotenv-expand/pull/121/files
install 11.0.5 and you should be all set
I can confirm: 11.0.5 is working. Thanks for the quick fix!
In addition to #117, there is also a breaking change when referencing a "real" env variable from a .env file.
For example:
Variable (set in docker environment):
APP_DOMAIN=example.com
Variable (set in .env):
BASE_URL=https://${APP_DOMAIN}/api/
Results in
https://${APP_DOMAIN}/api/
. In v10 it was correct:https://example.com/api/