Cloudinary Error: Must supply api_key
// Cloudinary.jsimport { v2 as cloudinary } from "cloudinary";import dotenv from "dotenv";dotenv.config();
// Configure Cloudinary using environment variablescloudinary.config({ cloud_name: process.env.CLOUDANARY_NAME, api_key: process.env.CLOUDANARY_API_KEY, api_secret: process.env.CLOUDANARY_SECKET_KEY,});export default cloudinary;
i try this code as docdocumentation but got this error eveevery time throw new Error(Must supply ${name}
);
^ Error: Must supply api_key
i checked all my api key secret key and cloud name but still got this error. How can i solve it
Comments
-
Hi there. Thanks for getting in touch.
Sometimes we see this with third party services such as Vercel, and it almost always boils down to environment variables not being configured properly, so that would be the first thing to check.
Could you please run this script and let us know the output?
// Requirements require("dotenv").config(); const cloudinary = require("cloudinary").v2; // Check the environment variables are set correctly 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})
Many thanks,
-Danny0