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

141
Views
Variable ambiental indefinida en React APP

Estoy tratando de establecer la URL de la API en tiempo de ejecución. Seguí este tutorial que resuelve el problema exacto que tengo, pero aún así, la variable no está definida.

Puse el archivo con variable ambiental en script en index.html (EDITADO)

 <script src="%PUBLIC_URL%/env-config.js"></script>

Dentro del cual hay (después de que la imagen comience a través de Docker) algo como esto:

 window._env_ = { API_URL: "my-awesome-url" // filled by bash script defined in ENTRYPOINT }

Pero cuando quiero usarlo en la aplicación React, aparece algo como " cannot read property of undefined API_URL . Cuando intento acceder al objeto de la window en la console , puedo ver que la variable _env_ no está presente en el objeto. ¿Qué me estoy perdiendo?

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

0

La etiqueta del script es incorrecta. Se supone que es como <script src="%PUBLIC_URL%/env-config.js"></script>

Verifique y vuelva a intentarlo.

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!