"Error: Must supply api_key" in Heroku log

ZachJ
ZachJ Member Posts: 8
edited February 29 in Developer APIs

Everything works fine when I run my app on the development side but after I deploy to Heroku and my site is in production, I see in the Heroku logs.. "Error: must supply api_key". Not sure what's happening here, does it have something to do with the "unsigned" setting? I made the update to "Unsigned uploading enabled" but that didn't fix it.

Also I just went through the process of connecting my heroku acct to cloudinary acct. Had to set up a new cloudinary acct through heroku and copy in the CLOUDINARY_URL to config vars in heroku. I'm still getting the error though.

Answers

  • ZachJ
    ZachJ Member Posts: 8
    edited February 29

    ...

  • DannyFromCloudinary
    DannyFromCloudinary Member, Cloudinary Staff Posts: 150

    Hey @ZachJ, thanks for getting in touch.

    It seems this may be an issue with how your environment variables are configured on the Heroku side, so it may be worth getting in touch with their support, as they will be better placed to provide assistance. There are a few things you can do though to check the configuration is working before reaching out to their support team:

    • You can check the environment variable returns correctly if you try to log it to the console. Please bear in mind you should never expose your API secret publicly, so try logging cloudinary.config().api_key or process.env.API_KEY to see if it's being set correctly.
    • You could try stopping and restarting the application
    • You could try fully redeploying the application.

    I hope this helps. Please let us know how it goes.

    Kind regards,

    -Danny

  • ZachJ
    ZachJ Member Posts: 8

    Ya console.log comes back as undefined. Do you see any issues with this?...

    cloudinary.config({

      cloud_name: 'hxne*****',

      api_key: process.env.CLOUDINARY_API_KEY,

      api_secret: process.env.CLOUDINARY_API_SECRET,

      secure: true  

      });


    And then in Heroku..

    Key is....CLOUDINARY_URL

    Value is....cloudinary://6946***********:zYBgelWb********_MQV*****@hxne*****

  • epasos
    epasos Member, Cloudinary Staff Posts: 25

    To ensure that the Heroku env config is loaded accordingly, could you try to redeploy your code after adding the Cloudinary config vars in Heroku?