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

175
Views
Calling API in production and development in react js

if the Url is localhost/8085

Then all api call will be made to localhost:9764/API

if the url is http://10.1xx.xx.xx:8085/Amp Then all api call using 10.1xx.xx.xx:9764/api...

Is This possible in React js?

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

0

You can get the host name (window.location.host) and do anything from that (https://stackoverflow.com/a/54691801/7174186)

about 4 years ago · Juan Pablo Isaza Report

0

it works for me.

const url=""
if(process.env.NODE_EnV==="development"){
   url =localhost:8085
}else if(process.env.NODE_EnV==="production"){
   url = "http://10.1xx.xx.xx:8085/Amp "
}
about 4 years ago · Juan Pablo Isaza Report

0

Assuming that your app was created with create-react-app, you can create two different .env files - .env.development and .env.production and create inside them variables with the same names. Therefore, if you run your app locally, the app will use variable values from .env.development and in production from .env.production.

//.env.development
REACT_APP_API_URL=ABC
//.env.production
REACT_APP_API_URL=DEF
//Component.tsx
const URL = process.env.REACT_APP_API_URL
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!