Search code examples
herokuapi-key

How should I store my API key on Heroku so that it still stays secret instead of embedding in web page code


I have built a Flak app, locally I have stored it as environment variable, but I do not know how should I store my API key on Heroku so that it still stays secret instead of embedding in web page code?


Solution

  • You can store your api-key as environment variables as these are perfectly secure:

    go to you local folder and run heroku config:set key_one=value_one key_two=value_two and more.

    Note: run above commands in the same folder which points to your repository.

    once you set the environment variable you can access this key value pair in you code directly as:

    var api_key = process.env.key_one;