Stéphane R.
Stéphane R.

Reputation: 1496

Meteor settings file error

I would like use settings.json for create the first user when i start my APP for the first time, but i've error on my browser.

My settings.json :

{
    "admin": {
        "username": "username",
        "password": "password"
    },
    "smtp": "smtp://[email protected]"
}

My /lib/userAccount.js :

let username = Meteor.settings.admin.username;

Accounts.createUser({
    username: username,
    password: 'steph0407'
});

And error return on browser :

Erreur : TypeError: Meteor.settings.admin is undefined

Do you have any idea why i've this error ?

Thak you !

Upvotes: 2

Views: 118

Answers (1)

Gemmi
Gemmi

Reputation: 1242

You should start meteor app with: meteor --settings ./path/to/settings.json

Remember also that anything in Your settings not under a key called "public" is only made available to the server. If you put something under a key called "public", it will be available to client and the server.

You should move userAccount.js to server folder or check if (Meteor.isServer) {} in Your lib folder.

Upvotes: 2

Related Questions