DEV Community

Why Doe
Why Doe

Posted on

Vercel asking for env variable I already provided...

Hi there, I'm new here!

I've uploaded my nextjs app to vercel, cloudinary doesn't seem to throw any errors at me and is storing my images just and I can display them on the app just fine.

https://codefile.io/f/ezzy3n1Pzd

Error: A Cloudinary Cloud name is required, please make sure NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME is set and configured in your environment.
Enter fullscreen mode Exit fullscreen mode

Here's where I configure my cloudinary service:

import {v2 as cloudinary} from "cloudinary";
//import "dotenv/config.js";
import dotenv from "dotenv"
dotenv.config();

cloudinary.config({
    cloud_name: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME,
    api_key: process.env.NEXT_PUBLIC_CLOUDINARY_API_KEY,
    api_secret: process.env.CLOUDINARY_API_SECRET    
})

export const POST = async(request: Request) => {
    const body = (await request.json()) as {paramsToSign: Record<string, string>};
    const {paramsToSign} = body;
    const signature = cloudinary.utils.api_sign_request(
        paramsToSign,
        process.env.CLOUDINARY_API_SECRET as string
    );
    return Response.json({signature});
}
Enter fullscreen mode Exit fullscreen mode

...and this is part of my .env file:

NEXT_PUBLIC_CLOUDINARY_API_SECRET= "*****************************"
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME= "*********"
NEXT_PUBLIC_CLOUDINARY_API_KEY= "************************"
NEXT_PUBLIC_CLOUDINARY_URL= "********************************************** ****************************"

CLOUDINARY_API_SECRET= "***********************"
CLOUDINARY_CLOUD_NAME= "************"
CLOUDINARY_API_KEY= "**************"

Enter fullscreen mode Exit fullscreen mode

keys are edited, obviously

I have dotenv installed, I tried passing the environment variables both in COULDINARY_ and NEXT_PUBLIC_CLOUDINARY_ formats, doesn't work...

Top comments (0)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay