Next.js Discord

Discord Forum

Different set of ENV variables for same project?

Answered
Russo-European Laika posted this in #help-forum
Open in Discord
Russo-European LaikaOP
I have a project that parses an excel sheet and then shows some insights according to it in a visual way. I want to open-source the code but the problem I am facing is I don't want folks to access the insights that are generated on my personal data, rather it can be some dummy data. How can I achieve this? The connection from the backend to the excel sheet is being done using Google Sheets API whose credentials are stored in the environment.

One approach that I can think of is creating another repository and then linking it with Vercel and using dummy data environment variables for that project. This would require me to make sure changes are synced in both the repos. Probably can be done by creating a post-commit hook.

I would love to get advice from folks on how to tackle this. Maybe this is what deployment environments are for, but I am not sure.
Answered by Rafael Almeida
in this case you need to create a second project from the same repo, then change the variables on the second projects with the dummy variables
View full answer

18 Replies

Russo-European LaikaOP
Bump
Russo-European LaikaOP
Thanks for answering, Rafael.

I am using '.env' variables for the project, but I also want a preview for other users as well and it shouldn't be on my personal data. That means some other set of '.env' variables should be used for them.
so its like a preview of what the tool can do? a live preview of the result? 🤔
Russo-European LaikaOP
It would be a deployed version of the project, just that the .env variables it would use would be different.
oh you can set environment variables from your host provider. here is a guide for vercel: https://vercel.com/docs/projects/environment-variables
instead of a .env file you usually set them on a dashboard for deployments
Russo-European LaikaOP
Yeah, I am using Vercel for that. I have one deployed version running on my personal data, I want to have one more that runs on dummy data.
in this case you need to create a second project from the same repo, then change the variables on the second projects with the dummy variables
Answer
Russo-European LaikaOP
Okay, I will give this a shot. So both projects will fetch from the same repo.
This approach should work, but I am bit worried about the deployment process updating this URL in the GitHub repo giving away the private deployment link.
Is there some way to make sure Vercel doesn't autofills the URL everytime it makes a new deployment?
uh I am not sure about this 🤔
Russo-European LaikaOP
If we can make sure the link doesn't get updated at all, then that will solve the issue.
@Russo-European Laika Is there some way to make sure Vercel doesn't autofills the URL everytime it makes a new deployment?
are you sure it is updated on every deployment? pretty sure this only happens once during project creation
you can always simply remove the link and it wont show up there again
@joulev are you sure it is updated on every deployment? pretty sure this only happens once during project creation
Russo-European LaikaOP
The URL is updated every time a deployment is done.
Russo-European LaikaOP
Bump