joaoqalves
joaoqalves

Reputation: 198

How to add configuration settings to locals on Sails.js

I'm building a webapp using Sails.js and I'm wondering how to have different configurations on development and production modes. I thought that I just had to put a configuration key in config/local.js but it doesn't work. Here's an example of what I'm trying to do:

config: {
    linkedIn_key: 'abcde',
    linkedIn_secret: '13mcas',
    linkedIn_url: 'http://localhost:1337/user/login'
}

I tried to access config in the UserController.js but I wasn't able to get the value. What is the right way to do it?

Best regards, João

Upvotes: 1

Views: 1560

Answers (1)

Robert Merten
Robert Merten

Reputation: 221

It should appear in sails.config. You can also try to create a new file: linkedin.js under the config folder and place your configurations there:

var linkedIn = {
   key: 'abcde',
   secret: '13mcas',
   url: 'http://localhost:1337/user/login'
};
module.exports.linkedin = linkedIn;

and access it in your controller via

sails.config.linkedin

Upvotes: 1

Related Questions