简体   繁体   中英

How can I check the environment variable in meteor

I'm a beginner of meteor, nodejs and mongo DB,

I knew meteor use local mongo db .

but I want to change it to mongolab ;

I started my web like this :

export MONGO_URL="mongodb://account:password@mymongolabdb:12345/mydb" 
meteor

I want to check MONGO_URL is right or not .

How can I do this ?

在服务器端代码中,您可以将其检查为process.env.MONGO_URL并进行打印。

Create a server method which returns process.env.MONGO_URL if you wish to have the value of this environment variable available on the client. On the client, make a call to this method. See Meteor documentation on methods on how to do this.

Be extremely careful though with this kind of checking. You are exposing your database URL to the client. Make sure you check whether the logged-in user is allowed to view this value. In the method you can use this.userId which gives you the userId of the user making the call to your method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM