私が試してみました:
alert(process.env.MONGO_URL);
どこにでも私のMeteorプロジェクトがあり、常に次のものを取得します。
Uncaught ReferenceError: process is not defined
何が間違っているのかわかりません。何かを含める必要がありますか?Meteorはjavascriptで記述されており、すべて同じAPIが利用できるのに、なぜプロセスが定義されていないのですか?
私が試してみました:
alert(process.env.MONGO_URL);
どこにでも私のMeteorプロジェクトがあり、常に次のものを取得します。
Uncaught ReferenceError: process is not defined
何が間違っているのかわかりません。何かを含める必要がありますか?Meteorはjavascriptで記述されており、すべて同じAPIが利用できるのに、なぜプロセスが定義されていないのですか?
あなたは試すことができます
if (Meteor.isServer) {
console.log(process.env);
}
サーバー側から環境を取得する必要があります。次のことを試してください。
//In the client side
if (Meteor.isClient) {
Meteor.call('getMongoUrlEnv', function(err, results) {
alert("Mongo_URL=",results);
});
}
if (Meteor.isServer) {
Meteor.methods({
getMongoUrlEnv: function(){
var mongoURL = process.env.MONGO_URL;
return mongoURL;
}
});
}
この機能でサーバー側環境をリクエストできます。
//In the client side
if (Meteor.isClient) {
Meteor.call('getEnv', "VARIABLE_NAME", function(err, results) {
alert(results);
});
}
if (Meteor.isServer) {
Meteor.methods({
getEnv: function(node){
return process.env[node];;
}
});
}