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

139
Views
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
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!