Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
One .env variable returns correctly but the other one is undefined in the same file

Context: This is a React application and I want to use a .env file to store my DB related credentials. This will probably change in the future, but I can't get this working for some reason.

.env:

REACT_APP_FAUNA_API_KEY=**************** // returns fine if I console.log() it and I can also use it in the rest of the code
FAUNA_DB_ID=***************** // returns undefined

db.js:

import faunadb from "faunadb";

require("dotenv").config();

const client = new faunadb.Client({
  secret: process.env.REACT_APP_FAUNA_API_KEY,
  domain: "db.eu.fauna.com",
  port: 443,
  scheme: "https",
});
const q = faunadb.query;
console.log(process.env.FAUNA_DB_ID);
const databaseID = process.env.FAUNA_DB_ID;

export { client, q, databaseID };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

For a CRA app (making a guess based on the REACT_APP_FAUNA_API_KEY variable), env vars will only be exposed to the front-end if they start with REACT_APP_

https://create-react-app.dev/docs/adding-custom-environment-variables/

If you rename the variable to REACT_APP_FAUNA_DB_ID, does it return correctly?

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!