I have a requirement to have a configurable key value pair like app key for an API which can change for different instance of my website. Is there a way to have configurable values for a key which can be dynamically loaded in the server side js code?
One standard way to do this would be to use environment variables, i.e. define them in the shell script or similar that starts the server and read them in the code using
Another option is to use Meteor.settings.
I have created settings.json file and added the below
I am trying to see if I can access this value in server.js file using the below code
But I get an exception as Undefined. Am I missing anything?
the settings.json is under the same folder which has server.js
You have to start meteor with the settings flag and pass in the path to that file
i have done it but doesnt work still. This is the output. Is the equals important?
C:\Users\Varesh Rangan\AppData\Local.meteor\Rakshak>“C:\Users\Varesh Rangan\App
Data\Local.meteor\meteor.bat” run --settings server\settings.json
[[[[[ ~.meteor\Rakshak ]]]]]
=> Started proxy.
=> Started MongoDB.
I20150531-12:25:18.388(5.5)? ** You’ve set up some data subscriptions with Meteo
I20150531-12:25:18.390(5.5)? ** you still have autopublish turned on. Because au
topublish is still
I20150531-12:25:18.391(5.5)? ** on, your Meteor.publish() calls won’t have much
effect. All data
I20150531-12:25:18.391(5.5)? ** will still be sent to all clients.
I20150531-12:25:18.391(5.5)? ** Turn off autopublish by removing the autopublish
I20150531-12:25:18.392(5.5)? ** $ meteor remove autopublish
I20150531-12:25:18.392(5.5)? ** … and make sure you have Meteor.publish() and M
=> Started your app.
=> App running at: http://localhost:3000/
Type Control-C twice to stop.
I20150531-12:25:18.392(5.5)? ** for each collection that you want clients to see
it worked. sorry I was looking at the wrong place.
Good that it worked!
And no, that’s not important.
meteor --settings settings.json will work as well!