Different API Urls for different environments(dev/staging/test/production) for a React App deployed to Kubernetes

Viewed 40

My question is regarding setting different API_ENDPOINTS for different environments(test/dev/staging/production) React App that is running in a Kubernetes container.

For dev environment API_ENDPOINT = 'https://dev-cluster.api/endpoint'
For test environment API_ENDPOINT = 'https://test-cluster.api/endpoint'
For staging environment API_ENDPOINT = 'https://staging-cluster.api/endpoint'
etc

Should I be creating a dynamic .env file from environment specific(each environment is on a different cluster) ConfigMaps and then accessing the api endpoint as process.env.API_ENDPOINT? If so, how to do that?

Or is there any way for the react app to directly access the ConfigMap? Or any other suggestions?

React App is created using CRA

0 Answers
Related