Unknown api key
I have made a social media web app using MERN stack. While using localhost, it works completely fine, but after deploying it to Render, it tells Unknown API key '123456789123456'. But it is the same API key which i'm using on localhost. I'm using environment variables to pass the API key to the configuration file. Not sure what to do now?
Best Answer
-
Hi Aditya. Thanks for getting in touch.
I've not used Render myself, however I have seen similar issues in the past with other platforms such as Vercel, where the way they work with environment variables differs from what you may expect.
Could you please confirm if you've followed the instructions for setting environment variables as defined here in Render's documentation? If so, it's worth doing a simple
console.log(cloudinary.config().api_key);
, and making sure the correct API key is returned.Please give this a try and let us know how it goes :)
0
Answers
-
Hi @DannyFromCloudinary , I did console.log(cloudinary.config().api_key). It's returning the correct API key in the format of - '123456789123456'. Is there any fix available for this issue?
0 -
Thanks for confirming. Do you get the correct information returned if you request cloudinary.config().cloud_name and cloudinary.config().api_secret also?
My suspicion is that Render isn't using the environment variables you have defined. For testing purposes, you could create some brand new API access credentials in your Cloudinary account by going into Settings -> Access Keys. You could then try hardcoding the credentials to check if environment vars aren't being respected. Of course, for safety's sake you should reactivate these test credentials in your Cloudinary settings.
I hope this helps. Please let us know the outcome.
0 -
Yes, hardcoding the cloud name, api key and api secret works. But environment variables aren't working.
0 -
Thanks for letting me know. This sounds like this is something that Render will need to assist you with then, as they will be able to determine why the environment variables aren't being made available to your application. You can reach them at support@render.com, and I recommend pointing them to this post for additional context.
If they have any queries which Cloudinary can help with, they are welcome to reply here, and we will do our best to collaborate with them to provide a positive outcome for you.
Sorry we're not able to help you directly in this instance, but do let us know if you have any further questions.
0