'how to use environment variables for production?
I am learning about environment variables. I need to use it in my code for production.
I know is not good practice to share your .env file when deploying your code because it contains sensitive information that you don't want to share with the public.
I do need to make my .env file visible because my code needs to use the api key to call the endpoints. Is the solution to deploy my code to a private repo so I can make my .env file visible?
Solution 1:[1]
It is not advisable to make your env
file public because it usually contains API key or other private credentials. For a local repository creating a .env
should be enough.
While deploying the application say over netlify, gh-pages, vercel or any other deployment platforms, you need to add the constants or variables defined in the env
file as it is before deploying the application.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jayraj Rathod |