Next.js Discord

Discord Forum

Environment Variables - API Open AI

Unanswered
Bigeye scad posted this in #help-forum
Open in Discord
Bigeye scadOP
Good evening friends, thank you for allowing me to join this great forum. For my school assignment, I am developing a simple chatbot using the OpenAI API using node.js.

Initially, I developed this chatbot using a local server (localhost:3000), and currently, I am trying to use Vercel so that it can be accessed continuously. However, there are obstacles that I experience. When developing, of course, I will use .env to place my API Key but when I try to upload it to the git repository page, of course, .env cannot be uploaded for security reasons, finally, I use the environment variable feature provided by Vercel to place my OpenAI API.

What I want to ask after I enter my environment variables in Vercel, is what do I need to change in my server.js? Thank you in advance 💫

3 Replies

@@ts-ignore changing env vars needs a redeploy
Bigeye scadOP
thank you for your response and answer, I redeployed it and nothing changed. I was stuck in this .env because it totally worked in my local host 😅

The left one is loaded using a local host, and the right one is from Vercel. The "Gagal memuat pertanyaan" means my chatbot failed to generate 3 random questions from the GPT like the left one.