I am trying to deploy my Meteor app to AWS Elastic Beanstalk. They don’t support JSON objects as environment variables so there needs to be a workaround. I am uploading a settings.json file to /tmp/settings.json and saving the path as process.env.METEOR_SETTINGS_FILE then in a server file I do the following:
if (Meteor.isProduction) {
var meteorFile = process.env.METEOR_SETTINGS_FILE;
if(meteorFile == undefined) throw new Error(
'METEOR_SETTINGS_FILE env variable must be defined in production.')
var fs = Npm.require('fs');
var pjsonBuf = fs.readFileSync( meteorFile );
Meteor.settings = JSON.parse( pjsonBuf.toString().trim());
Meteor.settings.public = Meteor.settings.public;
}
However, on the client I still get Uncaught TypeError: Cannot read property 'writeKey' of undefined where undefined needs to be Meteor.settings.public.segment. I have an empty object as Meteor.settings.public and if I console.log(Meteor.settings) in the file above, they are all there.