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)