Soporte de The Movie Database

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 respuestas (en la página 1 de 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.

¿No encuentras una película o serie? Inicia sesión para crearla:

Global

s centrar la barra de búsqueda
p abrir menú de perfil
esc cierra una ventana abierta
? abrir la ventana de atajos del teclado

En las páginas multimedia

b retrocede (o a padre cuando sea aplicable)
e ir a la página de edición

En las páginas de temporada de televisión

(flecha derecha) ir a la temporada siguiente
(flecha izquierda) ir a la temporada anterior

En las páginas de episodio de televisión

(flecha derecha) ir al episodio siguiente
(flecha izquierda) ir al episodio anterior

En todas las páginas de imágenes

a abrir la ventana de añadir imagen

En todas las páginas de edición

t abrir la sección de traducción
ctrl+ s enviar formulario

En las páginas de debate

n crear nuevo debate
w cambiar el estado de visualización
p cambiar público/privado
c cambiar cerrar/abrir
a abrir actividad
r responder al debate
l ir a la última respuesta
ctrl+ enter enviar tu mensaje
(flecha derecha) página siguiente
(flecha izquierda) página anterior

Configuraciones

¿Quieres puntuar o añadir este elemento a una lista?

Iniciar sesión