Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid Cloudinary Configuration

I'm new to keystone and am trying to deploy a simple website template to familiarise myself with the technology, I have downloaded all the necassary modules and created a keystone.js file and package.json file with all the dependencies. However, when I attempt to run keystone.js in the terminal I get the following:

 Error: Invalid Configuration

 CloudinaryImage fields (Gallery.heroImage) require the "cloudinary config" option to be set.

 See http://keystonejs.com/docs/configuration/#cloudinary for more information.

I have set up an account with cloudinary and used npm install to ensure it is installed in the system but it obviously can't find the configuration. I assume there is a simple solution to this and that I simply have to put my configuartion fields in the right place of the code but I can't seem to find any instructions as to where to insert my account details. Any help would be appreciated and please let me know if I have omitted any important code.

keystone.js:

    require('dotenv').load();

    // Require keystone
   var keystone = require('keystone'),
handlebars = require('express3-handlebars');


    // Initialise Keystone with your project's configuration.
   // See http://keystonejs.com/guide/config for available options
   // and documentation.


   keystone.init({

'name': 'Tech Website',
'brand': 'Tech Website',

'less': 'public',
'static': 'public',
'favicon': 'public/favicon.ico',
'views': 'templates/views',
'view engine': 'hbs',

'custom engine': handlebars.create({
    layoutsDir: 'templates/views/layouts',
    partialsDir: 'templates/views/partials',
    defaultLayout: 'default',
    helpers: new require('./templates/views/helpers')(),
    extname: '.hbs'
}).engine,

'auto update': true,
'session': true,
'auth': true,
'user model': 'Yes',
'cookie secret': 'pUO>=q^~Z.h]~pO"k;:]dTcTb:6pT3Xyassxdk>9K]7J0MGqSWWr;$rs6lG<XLdB'

});

    // Load your project's Models

keystone.import('models');

    // Setup common locals for your templates. The following are required for the
   // bundled templates and layouts. Any runtime locals (that should be set uniquely
  // for each request) should be added to ./routes/middleware.js

keystone.set('locals', {
_: require('underscore'),
env: keystone.get('env'),
utils: keystone.utils,
editable: keystone.content.editable
    });

    // Load your project's Routes

    keystone.set('routes', require('./routes'));

    // Setup common locals for your emails. The following are required by Keystone's
    // default email templates, you may remove them if you're using your own.

    // Configure the navigation bar in Keystone's Admin UI

    keystone.set('nav', {
'posts': ['posts', 'post-categories'],
'galleries': 'galleries',
'enquiries': 'enquiries',
'yes': 'yes'
});

// Start Keystone to connect to your database and initialise the web server

.start();

package.json

{
 "name": "tech-website",
  "version": "0.0.0",
  "private": true,
  "dependencies": {
  "keystone": "~0.2.27",
  "async": "~0.9.0",
  "underscore": "~1.7.0",
  "moment": "~2.8.1",
  "express3-handlebars": "~0.5.0",
  "handlebars": "^2.0.0-alpha.2",
  "dotenv": "0.4.0"
  },
  "devDependencies": {
  "grunt": "~0.4.4",
  "grunt-express-server": "~0.4.17",
  "grunt-contrib-watch": "~0.6.1",
  "grunt-contrib-jshint": "~0.7.1",
  "jshint-stylish": "~0.1.3",
  "load-grunt-tasks": "~0.4.0",
  "grunt-node-inspector": "~0.1.5",
  "time-grunt": "~0.3.1",
  "grunt-concurrent": "~0.5.0",
  "grunt-nodemon": "~0.2.1",
  "open": "0.0.5"
},
  "engines": {
  "node": ">=0.10.22",
  "npm": ">=1.3.14"
},
"scripts": {
"start": "node keystone.js"
},
"main": "keystone.js"
}
like image 670
denisq91 Avatar asked Oct 03 '14 13:10

denisq91


3 Answers

There are multiple ways you can configure Cloudinary in your KeystoneJS app.

One option is to set the CLOUDINARY_URL environment variable. You can do this in your .env file, since you're using dotenv.

CLOUDINARY_URL=cloudinary://api_key:api_secret@cloud_name

A second alternative would be to set the cloudinary config setting within your Keystonejs app.

You can do this either in your keystone.init()

keystone.init({
    ...
    'cloudinary config': 'cloudinary://api_key:api_secret@cloud_name',
    ...
});

... or using the keystone.set() method.

keystone.set('cloudinary config', 'cloudinary://api_key:api_secret@cloud_name' );

These were all detailed on the KeystonsJS Configuration page, but are not present anymore.

like image 88
JME Avatar answered Nov 18 '22 12:11

JME


Adding something -

Well what actually worked for me was when I placed the config setting part in the

keystone.init portion. using setters did not work for me.

keystone.init({
    ...
    'cloudinary config': 'cloudinary://api_key:api_secret@cloud_name',
    ...
});

Above code is the only one that worked flawlessly.

like image 33
saurshaz Avatar answered Nov 18 '22 12:11

saurshaz


Here's how I deployed to heroku. In keystone.js add a block to use environment variables:

if (keystone.get('env') == 'production'){
    keystone.set('cloudinary config', process.env.CLOUDINARY_URL);
    keystone.set('cookie secret', process.env.COOKIE_SECRET);
    keystone.set('mandrill api key', process.env.MANDRILL_API_KEY);
}

Then set the environment variables on your heroku instance through the command line:

$ heroku config:set MANDRILL_API_KEY=YOUR_API_KEY
$ heroku config:set CLOUDINARY_URL=cloudinary://api_key:api_secret@cloud_name
$ heroku config:set NODE_ENV=production
$ heroku config:set COOKIE_SECRET=YOUR_COOKIE_STRING
like image 1
Connor Leech Avatar answered Nov 18 '22 14:11

Connor Leech