Next.js Discord

Discord Forum

.env.local encryption

Unanswered
Northeast Congo Lion posted this in #help-forum
Open in Discord
Northeast Congo LionOP
is it required to encrypt .env files data ? i use spaceship and they don't have environment variable and they told me to include the .env file in the root of the project, but I'm not sure if this is secure or not.

90 Replies

Tricolored Blackbird
.env is only visible for server
@Tricolored Blackbird .env is only visible for server
Northeast Congo LionOP
so i dont have to worry about saving plain data on it without encryption ?
Northeast Congo LionOP
Ight thanks
@Northeast Congo Lion is it required to encrypt .env files data ? i use spaceship and they don't have environment variable and they told me to include the .env file in the root of the project, but I'm not sure if this is secure or not.
Rose-breasted Grosbeak
ehh no that's a bad practice.
..unless the env variables are meant to be public. firebase does this.

But make sure to not put anything that should be private in the env file, AND have it in the repo.
Keeping the repo private may be safer, but still avoid it.
@Rose-breasted Grosbeak ehh no that's a bad practice. ..unless the env variables are meant to be public. firebase does this. But make sure to not put *anything* that should be private in the env file, AND have it in the repo. Keeping the repo private may be safer, but still avoid it.
Northeast Congo LionOP
its not a repo, i use spaceship and its a shared hosting, they don't have environment variable and the cs told me to just put it in the root of the project, ik its a security risk i just dont know if i should encrypt it, since it has database connection and many other stuff that has to be encryptyed or hidden
if the file is only visible on the server then people can still have access to it no ?
Rose-breasted Grosbeak
I haven't used spaceship and idk how it works, but they probably have separate VMs or containers?
@Rose-breasted Grosbeak I haven't used spaceship and idk how it works, but they probably have separate VMs or containers?
Northeast Congo LionOP
"There is no special directory for it. Our shared hosting servers have a basic setup with the user level of access"
Northeast Congo LionOP
i will ecrypt it anyway but is it gonna damage performance ? if not what should i use to encyrpt it ?
@Northeast Congo Lion "There is no special directory for it. Our shared hosting servers have a basic setup with the user level of access"
Rose-breasted Grosbeak
Yeah I couldn't find any docs either. Really shady.

But with correct configuration it should be secure
@Northeast Congo Lion i will ecrypt it anyway but is it gonna damage performance ? if not what should i use to encyrpt it ?
Rose-breasted Grosbeak
Encryption technically won't work because you'd need the key in the code anyway
@Rose-breasted Grosbeak Encryption technically won't work because you'd need the key in the code anyway
Northeast Congo LionOP
my plan now is to include tghe env file outide the publics foldier
but im not sure if i can still make it accceasble from the projects
Rose-breasted Grosbeak
What stack are you using?
Why not deploy on vercel?
@Rose-breasted Grosbeak Why not deploy on vercel?
Northeast Congo LionOP
its for my client he has 1 more wordpress website and wants everyhting to be together
@Rose-breasted Grosbeak What stack are you using?
Northeast Congo LionOP
nextjs typescript
along with mysql
Rose-breasted Grosbeak
I'm no security expert, so I can't give any reliable advice

But if the data isn't critical/sensitive you should be fine
What does the site do?
Northeast Congo LionOP
its pretty much a static page for a groups of campant, but they had issues with there previous maintainer where they neevr added new datas to the webiste, so i made it dynamic with mysql, the point of the webiste is to showcase there companies and proejcts
the creds i have is mysql creds along with googledrive for image storage, aswell as SMTP
Rose-breasted Grosbeak
Uhhh what
Why do you need a database for that
@Rose-breasted Grosbeak Uhhh what Why do you need a database for that
Northeast Congo LionOP
to add and remove projects or there comapnies
edit etc
Rose-breasted Grosbeak
How many would there be?
A dozen?
Northeast Congo LionOP
around 25
Rose-breasted Grosbeak
That's very small
Northeast Congo LionOP
and each has like datas o it
Rose-breasted Grosbeak
Okay, how much ?
Northeast Congo LionOP
depends
Rose-breasted Grosbeak
I'm pretty sure you don't need a database, google drive for that amount of data
@Rose-breasted Grosbeak I'm pretty sure you don't need a database, google drive for that amount of data
Northeast Congo LionOP
i did a dashboard aswell to perform crud operation, i trained one of there employee
@Rose-breasted Grosbeak I'm pretty sure you don't need a database, google drive for that amount of data
Northeast Congo LionOP
it also stored 3 langauge in the db
Rose-breasted Grosbeak
The SQL database is also stored locally in the shared server?
Northeast Congo LionOP
so each data is stored 3 times in each langauge
@Northeast Congo Lion yep
Rose-breasted Grosbeak
That's fine
So the sensitive part is google drive keys?
Service account, whatever they call it
Northeast Congo LionOP
yep
and the STMP
Rose-breasted Grosbeak
SMTP?
Northeast Congo LionOP
its a mail service combined with nodemailer
@Northeast Congo Lion and the STMP
Rose-breasted Grosbeak
SMTP*
Rose-breasted Grosbeak
Ditch google drive, store images locally

Make a makeshift admin panel to edit data
And obfuscate the SMTP credentials
@Rose-breasted Grosbeak And obfuscate the SMTP credentials
Rose-breasted Grosbeak
Although if someone gets access, obfuscation won't do shit
@Rose-breasted Grosbeak Ditch google drive, store images locally Make a makeshift admin panel to edit data
Northeast Congo LionOP
when i spoke with there custom support they said they dint support file uplaoding via the dashboard so idk 🥲
the imgs and stuff is uplaoded via the dashbaord
Northeast Congo LionOP
for now all i wanna is host the webiste i have already migreated the database from postgresql to mysql im tired from this 🥲
@Rose-breasted Grosbeak Lol
Northeast Congo LionOP
ikr i dont know itsa weird fkin thing
@Rose-breasted Grosbeak Why would you do that..?
Northeast Congo LionOP
@Northeast Congo Lion when i spoke with there custom support they said they dint support file uplaoding via the dashboard so idk 🥲
Rose-breasted Grosbeak
You can't make an API endpoint to get files?
Northeast Congo LionOP
and that mf said i want everything to be together since i dont know shit
Should have just gone with firebase or the likes
@Rose-breasted Grosbeak Wut..
Northeast Congo LionOP
the hosting service doesnt support postgresql else if the hosting was up to me i had already hosted the webiste via the vercel for 2 month and it was working like a charm
but they had to make it difficult
Rose-breasted Grosbeak
🫂🫂
Northeast Congo LionOP
i was done 2 months ago if it wasnt for there shit request🥲
now i just wanna secure the env somehoiw and say bye to it [KEKWIGGLE](https://cdn.discordapp.com/emojis/877623036185026641.gif?size=48&animated=true&name=KEKWIGGLE)
Rose-breasted Grosbeak
Vercel has postgress free tier too ?
@Rose-breasted Grosbeak Vercel has postgress free tier too ?
Northeast Congo LionOP
free for lifetife via neondb
Northeast Congo LionOP
well you gotta pay if the data reachs its limit
but pretty much yea its free on most of the ways they proivede
and really good for debugging and performance check
Rose-breasted Grosbeak
Whose decision was it to choose spaceship?
Northeast Congo LionOP
their decision
Rose-breasted Grosbeak
Yeah so tell them the drawbacks. Let them deal with it
Northeast Congo LionOP
i mean i dont wanna tlak with them they dint know shit about it,
and probably think imscamming them
Rose-breasted Grosbeak
Don't get yourself a headache for their decisions lol
Northeast Congo LionOP
okay i know if they dont liisten i dont know what to do [YanfeiHMM](https://cdn.discordapp.com/emojis/837056665449660426.webp?size=48&name=YanfeiHMM)
i will just put the env file seperatly as in a private fodler and see how it goes during testing
i doubt the webiste will have many visitor anyway
i just dont wanna migrate the databse again uk i have been through alot already [crisps](https://cdn.discordapp.com/emojis/913704623355867166.gif?size=48&animated=true&name=crisps)
and im not getting paid for any of it so
Northeast Congo LionOP
Nvn i somehow forgot its not required during run time