Closed russelporosky closed 7 months ago
Could you set the "unsecure" flag to true in your angular.json file and share the output please?
Does console.log(import.meta.env.YOUR_ENV_VAR)
display the environment variable?
Actually @ngx-env/builder
(through esbuild) replaces "import.meta.env.YOUR_ENV_VAR
" in your source code by the actual values from your environment. The expression import.meta.env
itself is not replaced or mutated.
unsecure
doesn't seem to do anything - what was expected?
Console logging the specific var doesn't display anything, same as trying to use it in a component.
Could you please share the output in the console of npm start?
Figured it out by accident. I used the same var names the demo uses and it worked, and then I realized they have to start with NG_APP_
(although _NG_APP
works as well - maybe it just needs that text anywhere in the name).
That should be documented. I wasted a goodish amount of time expecting APP_API_URL
and FIREBASE_STORAGE
to work.
Sorry for that, still restructing the docs and working on https://dotenv.run.
The original @ngx-env/builder documentation is here https://github.com/chihab/dotenv-run/tree/main/packages/angular
When I run
npm run start
, it appears that my.env.local
file is being loaded (it's listed under "Environment Files"), but the values in it aren't shown like in the demos, and they aren't loaded in the app. If Iconsole.log(import.meta.env)
, only the built in ones appear:I've modified
env.d.ts
to have the keys I want (APP_BASE_URL: string
for example).I am using the Angular project variation - so my source code is actually in a
projects
folder and not the defaultsrc
folder.