Where to put frontend javascript configuration variables
<p>I have a Javascript frontend that does Ajax calls to my backend. To do that, it needs a "backend_URL" that I hard-coded in the Ajax get() call, say "<a href="http://myservice/backend" rel="noreferrer">http://myservice/backend</a>". </p>

<p>Now if I want to deploy my app on different machines, some of which will use this url with HTTPS: "<a href="https://myservice/backend" rel="noreferrer">https://myservice/backend</a>", and some not (because they lack a proper certificate and do not expose valuable data).</p>

<p>Where should I put the "USE_HTTPS=1" config variable so that someone deploying the app can choose to use or not SSL ? Of course the question extends itself to other config variables.</p>

<p>I thought about adding a ".config" file at the project root, but then I don't know how to import it in my code. Or should I export environment variables ? Or a node.js feature ?</p>