score:0

if you check the heroku build log, it recommends that you specify a nodejs version. if you specify a node version in your package.json, it might fix the problem.

package.json

{
...
  "engines": {
   "node": "12.13.1"
   },
...
}

score:2

you're trying to access the environment variable on client side and this is not possible.

if you want to use environment variables on your client side application you need to set up webpack to handle different environments.

in webpack config files, you’ll define your global variables for each environment using webpack’s define plugin.

also don't forget to add node_env config variable to your heroku app and set it to true. so you'll be sure that by accessingprocess.env.node_envwill force runtime to usenode.js` environment.

now you can configure you're production environment as following:

/* in webpack.config-prod.js */
...,
plugins: [    
  new webpack.defineplugin({           
    node_env: json.stringify(process.env.node_env),      
    api_host: json.stringify(process.env.api_host)
  })
],
...

now you can easily access you're environment variables in your client side app.


Related Query

More Query from same tag