I have built an application in python/flask and try to deploy it using Heroku. I have stored the credentials like an API-Key in a .env file. When running locally, everything seems to work and the code successfully receives the API Key from the env-file. When running on Heroku however, I get error messages regarding the missing key. When putting the key directly in the code, everything works – also in production.
To be clear, I integrated the .env file in the .gitignore file, so its not uploaded to github. As I am still quite the noob regarding webdevelopment, I am not sure what I am missing. Also, if the .env file is not in github, where does the code get the credentials from?
This is how the beginning of my file looks like
from dotenv import load_dotenv
import os
load_dotenv()
HERE_API_KEY = os.getenv("HERE_API_KEY")
In the .env file the key is stored like this:
HERE_API_KEY=example12345