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

140
Vistas
Serve precompiled JS file with changed ENV params depending on the request

Inspired by the Google Maps API way of fetching JS file I would like to serve my clients a JS file with compiled ENV variable depending on their request parameters. I know that Google's way is for authentication only.

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
async defer></script>

So if my customer would use this in theirs HTML

<script src="https://myapi.com/api/js?myEnvVariable=VARIABLE_VALUE" async defer></script>

they would get a script that would contain this value built somewhere inside and effectively mimic the use of .env files.

var someValue = VARIABLE_VALUE;

What would be the best option to do that?

  • Build separate JS file for each customer/parameter and then serve the right file
  • Read JS as string, find & replace some placeholder with the requested parameter and return to user
  • Use global window.myEnvVariable=VARIABLE_VALUE on client and do not complicate
  • Some standard way I am not aware of :)

Any ideas?

about 4 years ago · Juan Pablo Isaza
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