Υποστήριξη για το 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 απαντήσεις(στη σελίδα 1 από 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.

Δεν μπορείτε να βρείτε κάποια ταινία ή σειρά; Συνδεθείτε για να τη δημιουργήσετε.

Σε όλες τις σελίδες

s Εστίαση στη μπάρα αναζήτησης
p Άνοιγμα μενού προφίλ
esc Κλείσιμο ανοιχτού παραθύρου
? Άνοιγμα παραθύρου συντομεύσεων πληκτρολογίου

Στις σελίδες μέσων

b Επιστροφή στην προηγούμενη σελίδα(ή στην αρχική σελίδα όταν είναι εφικτό)
e Μετάβαση στη σελίδα επεξεργασίας

Στις σελίδες κύκλων σειρών

(Δεξιό βέλος) Μετάβαση στον επόμενο κύκλο
(Αριστερό βέλος) Μετάβαση στον προηγούμενο κύκλο

Στις σελίδες επεισοδίων σειρών

(Δεξιό βέλος) Μετάβαση στο επόμενο επεισόδιο
(Αριστερό βέλος) Μετάβαση στο προηγούμενο επεισόδιο

Σε όλες τις σελίδες εικόνων

a Άνοιγμα παραθύρου προσθήκης εικόνας

Σε όλες τις σελίδες επεξεργασίας

t Άνοιγμα επιλογέα μετάφρασης
ctrl+ s Υποβολή φόρμας

Στις σελίδες συζήτησης

n Δημιουργία νέας συζήτησης
w Ρύθμιση κατάστασης παρακολούθησης
p Ρύθμιση ως δημόσια/ιδιωτική
c Ρύθμιση ανοίγματος/κλεισίματος
a Άνοιγμα δραστηριότητας
r Απάντηση στη συζήτηση
l Μετάβαση στην τελευταία απάντηση
ctrl+ enter Υποβολή μηνύματος
(Δεξιό βέλος) Επόμενη σελίδα
(Αριστερό βέλος) Προηγούμενη σελίδα

Ρυθμίσεις

Θέλετε να αξιολογήσετε ή να προσθέσετε αυτό το στοιχείο σε μια λίστα;

Σύνδεση