1

I am working with Node and process.env.NODE_ENV is not available on the client (process itself is not available on the client). What is the best way to tell the client what environment you are in -for example, development or production?

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817

1 Answers1

1

Probably the easiest would be to create a server method that did the process.env and returned it in the format you want to the client.

// client.js
Template.body.rendered = function () {
  Meteor.call('getEnv', function (error, data) {
    console.log(data);
  });
};

// server.js
Meteor.methods({
  getEnv: function () {
   var nodeEnv = process.env.NODE_ENV;
   if (typeof(nodeEnv) !== 'undefined') {
      // nodeEnv environment variables exists, lets return it
      return process.env.NODE_ENV;
   }
  }
});
Ethaan
  • 11,291
  • 5
  • 35
  • 45
pstuart2
  • 362
  • 1
  • 5