m.ashrafi
m.ashrafi

Reputation: 11

How do I change the api addresses in the build of the React project?

In my React project, I want to change the api addresses after build it. I want to be able to change their address dynamically. is There a way I can do this? I do not want to use the environment. Because when I get build, I can not change api address

Upvotes: 0

Views: 123

Answers (1)

fortunee
fortunee

Reputation: 4332

Use the NODE_ENV env variable to check the environment

if (process.env.NODE_ENV === 'production') {
  // Set the API URL for prod
}

Set NODE_ENV=production when running your build script

Upvotes: 1

Related Questions