0

I would like to get info from GitHub API from browser JS on my website hosted on Heroku.

I have thought of two ways to do this:

  1. Hide an API key in a config var and read the config var in JS

    I went with this option and I ran into an issue:

    To hide the API key I would need to make a config var in the settings of my project, then read it using browser (not Node) JavaScript. I currently am stuck on reading the config var using JS.

  2. Through a GitHub workflow run on push (or whatever event)

    This is an advantage because I can read the repo from inside a workflow and not need to use a key (I think). Then the workflow would write data to a file on the website.

6
  • I still don't understand what you're trying to do. You're trying to get the GitHub API Key from your Heroku app settings using just client-side JS? Commented Oct 20, 2021 at 16:08
  • Is it not possible to do this? Commented Oct 20, 2021 at 22:07
  • If you're answering "yes" for my question, then it is possible. You'll need a server-side language like NodeJS or PHP to read the environment variables then output them for client-side JS to read. See this question for more details. Commented Oct 21, 2021 at 19:59
  • I don't know if I'm supposed to do this, but I flagged my question as a duplicate. Thanks for your help! Commented Oct 22, 2021 at 22:58
  • Does this answer your question? Unable to access API key in Heroku Config Vars from Javascript app Commented Oct 23, 2021 at 6:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.