"Must supply api_key" use cloudinary in production any recommendations
console.log("Esto es el cloud_name de cloudinary", process.env.cloud_name);
console.log("Esto es el api_key de cloudinary", process.env.api_key);
console.log("Esto es el api_secret de cloudinary", process.env.api_secret);
cloudinary.config({
cloud_name : process.env.cloud_name,
api_key: process.env.api_key,
api_secret : process.env.api_secret,
secure: true
})
Answers
-
Hey @scorpinos. Thank for getting in touch.
I'm assuming outputting your environment variables to the consoles results in an empty string - is that correct? We've seen this happen in the past when deploying sites to Netflify and other similar platforms, and most commonly, the issue is either with that third party having a different naming convention for environment variables, or the env vars not being configured/set in the UI. Ultimately, you may need to reach out to their support, rather than ours, but we'll do our best to help where we can.
Kind regards,
-Danny0 -
At first when I tested the value of the variables they were undefined but then I fixed that detail and got the environment variables working in development. but I received the same problem. I even did a test with direct values without using environment variables and the error was the same. What you receive from Cloudinary is "Must supply api_key" I don't know what else to do. The thing is that if the failure were to reveal more details, perhaps it would be possible to see how one would go about solving it. but the fault is the same "Must supply api_key"It worked wonderfully in development for almost a year and it still works for testing but in development it doesn't work.Please I need help.
0 -
There is a test that can be performed to determine what the real fault is. There must be some obvious problem but how do we detect it? In order to upload an image I must use the development version that I have in Visual Studio Code. If it works there, otherwise it doesn't.
0 -
I am really overwhelmed, after having worked for a year and three months using cloudinary and now when I move to development I don't have anyone on the Cloduinary side who speaks to me in clear, understandable words. Your help is Cloudia, an AI that doesn't let me tell me that if I want to go to development I must specify in the config object. an additional value cname : "https://res.cloudinary";
0 -
If the Cloudinary SDK works locally and only fails in production, then there must be some additional configuration required via whatever it is you're using to host the site. Be it Vercel, Heroku, or something different.
One way to test if it's the absence of environment variables, or if it's an issue with Cloudinary, would be to run this script in your production environment:
// Requirements require("dotenv").config(); const cloudinary = require("cloudinary").v2; // Check the environment variables are set correctly // Note: environment variables are case-sensitive if (!process.env.CLOUD_NAME || !process.env.API_KEY || !process.env.API_SECRET) { console.error("Environment variables not set"); return; // End script upon error } // Configure the Cloudinary object cloudinary.config({ cloud_name: process.env.CLOUD_NAME, api_key: process.env.API_KEY, api_secret: process.env.API_SECRET, secure: true }); // Check the Cloudinary object is correctly set up if (!cloudinary.config().cloud_name || !cloudinary.config().api_key || !cloudinary.config().api_secret) { console.error("Cloudinary config not set up"); return; // End script upon error } // Log the config parameters const cloudName = cloudinary.config().cloud_name; const apiKey = cloudinary.config().api_key; console.log({cloudName, apiKey}) // api_secret not logged, for security reasons
Could you please give that a try?
Thanks,
-Danny0 -
At first when I tested the value of the variables they were undefined but then I fixed that detail and got the environment variables working in development. but I received the same problem. I even did a test with direct values without using environment variables and the error was the same. What you receive from Cloudinary is "Must supply api_key" I don't know what else to do. The thing is that if the failure were to reveal more details, perhaps it would be possible to see how one would go about solving it. but the fault is the same "Must supply api_key" It worked wonderfully in development for almost a year and it still works for testing but in development it doesn't work. Please I need help.
0 -
Hi again @scorpinos.
Could you please let me know:
- What platform are you deploying to?
- What is the output of the script I've shared above when run in your development environment?
- What is the output of the script I've shared above when run in your production environment?
Kind regards,
-Danny0