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

152
Views
Why react doesn't see .env

I have .env which has T_APP_API_URL = http://localhost:5000/. I use it in this code snippet

import axios from "axios";

const host = axios.create({
    baseURL: process.env.REACT_APP_API_URL
});

const authHost = axios.create({
    baseURL: process.env.REACT_APP_API_URL
});

When I try to output console.log(process.env.REACT_APP_API_URL); then the value is displayed undefined, why is that? The .env file is located in the directory where all client files are present

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

first install dotenv: npm i dotenv
after that import this to file: const dotenv = require("dotenv")
and config dot env: dotenv.config()
about 4 years ago · Juan Pablo Isaza Report

0

Please check your .gitignore file, sometimes the create-react-app adds .env file to the .gitignore entry. Maybe that's the reason.

about 4 years ago · Juan Pablo Isaza Report

0

Did you try the dotenv package?

npm install dotenv

In your config file add:

require("dotenv").config();
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!