The easiest, multiplaform way to store environmental variables is by using .env file in the root of our project.
Now, the problem I'm facing is related to Firebase, more precisely Cloud Functions for Firebase. For all environmental variables accessed via process.env.SOME_VARIABLE I'm getting undefined, until the time of copying .env file to my deployment folder. In this case it's the default's functions, only then it works.
The question: is there any way to do so without duplication of the .env file? Across all my (Angular with Angular Universal) app I can access the process.env.SOME_VARIABLE, excluding the backend logic, which is 100% relying on functions.
I've tried to debug it
console.log(require('dotenv').config({ debug: true }));
Returned me something like workspace/.env in the Firebase's logs, but couldn't do anything with that.
Some of my trials:
require('dotenv').config({ path: '/workspace/.env' });
require('dotenv').config({ path: join(process.cwd(), '.env') });
require('dotenv').config({ path: join(process.cwd(), './../.env') });
require('dotenv').config({ path: __dirname + './../.env' });
require('dotenv').config({ path: join(process.cwd() + './../.env') });
Always gave me undefined, unless the .env was manually copied to the deployable functions folder.