0
  1. I am using dotenv npm package to hide sensitive data in my app. The config variables for backend and frontend/React are defined locally inside .env file. The app works fine locally.

  2. I deployed my app to Heroku and added config variables manually to Heroku.

  3. I have 4 variables, 3 for backend, 1 for React. While the VARs for backend works properly in Heroku, the VAR which I use in React to fetch data from external API returns undefined.

  4. React var has a prefix REACT_APP_ and as I said above it works fine locally and I can fetch data from external API. The only problem I have is, it doesn't work in Heroku.

0

1 Answer 1

0

I fixed the problem by removing the requirement for dotenv module in front-end. Simply I removed the code below and deployed to Hereoku again.

const path = require('path');
require('dotenv').config({path: path.resolve(process.cwd(), 'client', '.env.development'), debug: true});
Sign up to request clarification or add additional context in comments.

Comments

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.