Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

151
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda