I've created an app on AngularJS and Firebase. I decided to store the Firebase credentials as environment variables. I am on Ubuntu, and I run the development server using Grunt.
I tried creating a .bashrc file to store the environment variables as shown below (with the values inserted between the quotes).
export APIKEY=""
export AUTH_DOMAIN=""
export DATABASE_URL=""
export STORAGE_BUCKET=""
export MESSAGING_SENDER_ID=""
I then have a config.js file that uses these variables to configure Firebase.
var config = {
apiKey: process.env.APIKEY,
authDomain: process.env.AUTH_DOMAIN,
databaseURL: process.env.DATABASE_URL,
storageBucket: process.env.STORAGE_BUCKET,
messagingSenderId: process.env.MESSAGING_SENDER_ID
};
firebase.initializeApp(config);
However, I think Grunt does not pick up these values, because whether I run the Grunt server or run the app using node server.js, it doesn't find a value for these variables. I also tried creating the variables from the command line first, like so (with the value inserted between the quotes).
$ export APIKEY=""
Regardless, my app is unable to see the environment variables. It delivers this error in the console.
Uncaught ReferenceError: process is not defined at config.js:2
The app runs fine when I insert the values directly into the config.js file. I tried a variety of options for configuring variables in Ubuntu, and none seem to be working.
Edit:
It also might be worth noting that Heroku also does not recognize the variables, though I have registered them with Heroku, and it delivers the same error (process is not defined). Could it be something with Angular?