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

Problem courtesy of: joaoqalves


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

Solution courtesy of: Robert Merten


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.