Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use .env file while deploying my app?

I want to deploy my app using Heroku but I have kept my API keys in .env file which will be ignored by .gitignore file while pushing to Heroku and after deploying my app on Heroku, it is no longer able to read my API keys and app crashes? What to do in this case? How to use it correctly?

like image 917
Smile001 Avatar asked Jan 31 '26 22:01

Smile001


1 Answers

If your not storing your .env file in your git repository (which is absolutely the correct thing to do) then you need to manually configure the .env file once you deploy it.

In the instance of Heroku you can set Config Vars:

Configuration and Config Vars

If you do it that way I believe you have to access the vars in a different manor to env values but it has a local mode so that shouldn't be a problem.

like image 158
UrbanwarfareStudios Avatar answered Feb 02 '26 10:02

UrbanwarfareStudios



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!