The Movie Database-støtte

pls how do I prevent my API key from being exposed,
I'm using next.js and i have my .env file like this: NEXT_PUBLIC_MOVIEDB_APIKEY=KEY, and i read it well in the application but in production,
I want to hide it in my repo. I'm using vercel for that.
in my gitignore file the .env is included but once its in production it doesn't work anymore.

2 svar (på side 1 av 1)

Jump to last post

@dylanokeks said:
API KEY .env
pls how do I prevent my API key from being exposed,
I'm using next.js and i have my .env file like this: NEXT_PUBLIC_MOVIEDB_APIKEY=KEY, and i read it well in the application but in production,
I want to hide it in my repo. I'm using vercel for that.
in my gitignore file the .env is included but once its in production it doesn't work anymore.

I think that by adding some keywords to the title of this conversation, maybe other users will more easily understand the problem and can help.
Hide API Key - Vercel Next.js ,env file

add the environment variable to your vercel dashboard so vercel has access to it in prod as well. it will work fine in dev env since youre reading everything straight from sourc code. but vercel doesnt have access to github files that are ignored. .env file is ignored so you need to explicitly tell vercel what the key is. this is a generic rule and applies to any host that is deploying your github code.

Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p åpne profilmenyen
esc lukk et åpent vindu
? open keyboard shortcut window

On media pages

b gå tilbake (eller til foreldresiden når mulig)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Innstillinger

Vil du vurdere eller legge til dette elementet i en liste?

Logg inn