Hi, if I have my code deployed on a server from a repository, will hiding my api key using this method so that it is not visible in the repo affect anything?
That's a good question. Firstly, if you're uploading your code to GitHub, make sure you add ".env" to your ".gitignore" file to prevent it being accidentally committed to your repo. (You probably know that already but I'm mentioning it just in case.) Regarding deploying your code to a server, don't use a ".env" file. Instead, set environment variables directly on the server using your hosting platform's built-in method (I've listed some common ones below). If your host doesn't allow that, you can set environment variables using the command line (export API_KEY="my-api-key") or in a shell startup file. Hope that helps. - AWS EC2: You can set environment variables in the user data script when launching an instance, or use AWS Systems Manager Parameter Store or AWS Secrets Manager for more sensitive data. - AWS Lambda: You can set environment variables in the AWS Lambda console, AWS CLI, or AWS SDKs. - Heroku: You can use the Heroku CLI or the Heroku dashboard to set config vars. - Docker: You can set environment variables using the `-e` flag when starting a container, or by including the `ENV` command in your Dockerfile. - Kubernetes: You can set environment variables in your pod's YAML configuration file.
@@deepali4149 Hi again. Just letting you know that I made a quick video to answer your question in a bit more detail: ua-cam.com/video/WhLyrmp1AY4/v-deo.html
Thanks for this. I've seen other references to env variables but your instructions are clear and concise.
You're welcome Bill. Very happy to hear that it was useful.
So useful and beginner- friendly, thanks for sharing.
I have tried your method of setting .env, it worked well. Thanks again. 👍
@@CuriousJayDiscover Oh, I'm really happy to hear that. Glad it worked and thanks for the kind words!
Sir, was dotenv depends on the name of your parent folder?
Very helpful!
Hi, if I have my code deployed on a server from a repository, will hiding my api key using this method so that it is not visible in the repo affect anything?
That's a good question. Firstly, if you're uploading your code to GitHub, make sure you add ".env" to your ".gitignore" file to prevent it being accidentally committed to your repo. (You probably know that already but I'm mentioning it just in case.)
Regarding deploying your code to a server, don't use a ".env" file. Instead, set environment variables directly on the server using your hosting platform's built-in method (I've listed some common ones below). If your host doesn't allow that, you can set environment variables using the command line (export API_KEY="my-api-key") or in a shell startup file. Hope that helps.
- AWS EC2: You can set environment variables in the user data script when launching an instance, or use AWS Systems Manager Parameter Store or AWS Secrets Manager for more sensitive data.
- AWS Lambda: You can set environment variables in the AWS Lambda console, AWS CLI, or AWS SDKs.
- Heroku: You can use the Heroku CLI or the Heroku dashboard to set config vars.
- Docker: You can set environment variables using the `-e` flag when starting a container, or by including the `ENV` command in your Dockerfile.
- Kubernetes: You can set environment variables in your pod's YAML configuration file.
@@PuppyCoding Thank you for the response!
@@deepali4149 You're welcome!
@@deepali4149 Hi again. Just letting you know that I made a quick video to answer your question in a bit more detail: ua-cam.com/video/WhLyrmp1AY4/v-deo.html
@@PuppyCoding thanks… I’ll check it out :)