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

365
Views
How to update environment variable dynamically before npm start in React (variable for IP address)

Actually, I am trying to set the REACT_APP_DEPLOY_DOMAIN variable automatically in .env file.

below is one method I tried to achieve the solution to this issue.

below is my script file in which I am getting my IP address

const os = require("os");

const networkInterfaces = os.networkInterfaces();
const ip = networkInterfaces["Wi-Fi"][1]["address"];

REACT_APP_DEPLOY_DOMAIN = `http://${ip}`;
console.log(`http://${ip}`);
return `http://${ip}`;

below is the env variable in .env file

REACT_APP_DEPLOY_DOMAIN =  http://192.168.1.114

And also I tried to update it from the start command but it is setting it as the exact command

    "start": "set REACT_APP_DEPLOY_DOMAIN=node ./src/components/getIp.js && react-scripts start",

And also my script file is not running when I try to run the below command.

"start": "node ./src/components/getIp.js && react-scripts start",
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Update the start command to this, it works on Linux/Mac. Hopefully, it'll also work on windows

"start": "set REACT_APP_DEPLOY_DOMAIN=$(node ./src/components/getIp.js) && react-scripts start",
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!