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?
Asked
Active
Viewed 161 times
1 Answers
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;
}
}
});