Variable environment workflow
Unanswered
Guillaume630 posted this in #help-forum
![Avatar](https://cdn.discordapp.com/avatars/512678069509685458/ae65439e5807ccfe0d37e692820b02e1.webp?size=256)
Guillaume630OP
Hello there, I have different versions of my upcoming application (main and staging, mostly). My problem is that I need different environment variables that correspond to my application's version due to the version control workflow.
For example, if my Next app is in the staging environment, I require the staging environment variables from Supabase. The same goes for production and development environments.
Do you have any ideas on how to streamline the development process? Perhaps a VS Code plugin or a method that's quicker than copy-pasting?
For example, if my Next app is in the staging environment, I require the staging environment variables from Supabase. The same goes for production and development environments.
Do you have any ideas on how to streamline the development process? Perhaps a VS Code plugin or a method that's quicker than copy-pasting?
8 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
Somali
Vercel should be able to do this for you out of the box per domain / git branch
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/c78dd8e985ede1ad50c31ac682dd91a1.webp?size=256)
risky
can you not use their config (and branch for staging?)
![Image](https://cdn.discordapp.com/attachments/1162296155212877965/1162297067868262400/image.png?ex=653b6c7f&is=6528f77f&hm=37f0406915bd8065991517da318e338e5d4db900b229c4b1c8a3131413a88a50&)
ohh your not OP ðŸ˜
![Avatar](https://cdn.discordapp.com/avatars/512678069509685458/ae65439e5807ccfe0d37e692820b02e1.webp?size=256)
Guillaume630OP
Oh it's okay on vercel, my question is about y VS code config / Next project, that i have different environnement, when i switch main branch to staging, i need to have the .env.local related to staging
ex in .env.local in the Next project:
main branch
NEXT_PUBLIC_SUPABASE_URL="main_url"
staging branch
NEXT_PUBLIC_SUPABASE_URL="staging_url"
ex in .env.local in the Next project:
main branch
NEXT_PUBLIC_SUPABASE_URL="main_url"
staging branch
NEXT_PUBLIC_SUPABASE_URL="staging_url"
Should I everytime copy / paste the environment variable or there is a workflow to manage this automaticaly ?
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
Somali
Use VS Code workspace settings to load specific environment variables depending on the git branch you’re on @Guillaume630
{
"settings": {
"terminal.integrated.env": {
"NEXT_PUBLIC_API_URL": "${workspaceFolder}/.env.local" // Default for the "main" branch
},
"[development]": {
"terminal.integrated.env": {
"NEXT_PUBLIC_API_URL": "${workspaceFolder}/.env.local.development" // For the "development" branch
}
}
}
}
You can use the
.env.local
file to store your main URL while the .env.local.development
file has your staging URL.