I see a bunch of environment settings here:
http://meteorpedia.com/read/Environment_Variables
But how can I set them in settings.json?
Specifically these ones:
MONGO_URL
PORT
ROOT_URL
I see a bunch of environment settings here:
http://meteorpedia.com/read/Environment_Variables
But how can I set them in settings.json?
Specifically these ones:
MONGO_URL
PORT
ROOT_URL
You can’t set those in settings.json
, those specific variables belong exclusively in the environment if I’m not mistaken.
@ffxsam is right. Those environment variables along with a few others that you might find (S3 credentials in my case) cannot be set in settings.json
and must either be set with an export
or set in the environment variables of your deployment.
S3 credentials (and other super secret stuff) can be in settings.json
, it just needs to be under private {}
, and one should be careful to never check a settings.json
file containing secret keys into a repository site such as GitHub or BitBucket (even if it’s a private repo!). I’ve worked around this by setting up a .gitignore
to ignore settings.json
, and when I deploy, Jenkins will use scp
to securely copy settings.json
from a particular folder on the production server into the local workspace before it builds/deploys.
(sorry if that was a bit off-topic)
Sorry I should have prefaced this. S3 credentials can be set in Meteor.settings but some packages/npm modules try to grab them before they are accessible the same way meteor sets up the MONGO_URL
, ROOT_URL
, and PORT
. The reason these need to be set beforehand is because by the time they are read from the settings.json
file it will already be too late.
+1 on this being confusing.
Reaction Commerce initializes with a settings/dev.settings.json
that look like it’s expecting values so I tried adding a MONGO_URL
and PORT
to no avail:
{
"ROOT_URL": "",
"MAIL_URL": "",
"reaction": {
"REACTION_USER": "",
"REACTION_AUTH": "",
"REACTION_EMAIL": ""
},
"isDebug": "info",
"public": {}
}
Also, thank you @ccorcos for the link to Meteorpedia Environment Variables. I couldn’t find an example or docs on all the available settings spelled out anywhere until that.
This depends on the environment you’re running on. So for example, if you’re developing and running meteor locally, MAIL_URL
needs to be set in your shell environment, not settings.json
. So I have a script that looks like this:
#!/bin/sh
export AWS_ACCESS_KEY_ID="xx"
export AWS_SECRET_ACCESS_KEY="xx"
export AWS_REGION="us-west-2"
export MAIL_URL="smtp://xx:yy@smtp.sendgrid.net:587"
meteor $*
And then in my package.json
I have the following:
"scripts": {
"meteor": ".scripts/run-meteor --settings settings.dev.json",
},
But when you’re deploying to Galaxy, for instance, you need to have those vars set in a different settings file, e.g. settings.prod.json
:
"galaxy.meteor.com": {
"env": {
"MAIL_URL": " .... "
}
}