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.

  • 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? – JM-AGMS Oct 20 '21 at 16:08
  • Is it not possible to do this? – circles.png Oct 20 '21 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](https://stackoverflow.com/questions/65260762/unable-to-access-api-key-in-heroku-config-vars-from-javascript-app). – JM-AGMS Oct 21 '21 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! – circles.png Oct 22 '21 at 22:58
  • Does this answer your question? [Unable to access API key in Heroku Config Vars from Javascript app](https://stackoverflow.com/questions/65260762/unable-to-access-api-key-in-heroku-config-vars-from-javascript-app) – Daniel Widdis Oct 23 '21 at 06:01
  • Thanks for your help too, yes that question helped! – circles.png Oct 24 '21 at 02:30

0 Answers0