You can use Angular environment.ts file to configure your backend URLs.
In fact you can assign multiple backend url as you wish. For example (prod, dev, qa)
// environment.ts
export const environment = {
production: false,
baseUrl: 'http://localhost:3333'
};
// environment.prod.ts
export const environment = {
production: true,
baseUrl: 'https://jsonplaceholder.typicode.com'
};
// environment.qa.ts
export const environment = {
production: true,
baseUrl: 'https://jsonplaceholder.typicode.com'
};
Then you can build the angular project with relevent environment you prefer. Angular will assign the base urls acccording to the passed parameter in build time.
ng build --configuration=prod
ng build --configuration=qa
From herewith Im attaching reference link of official angular documentation on how to do it here.
Also please find the practical demonstration here. Please refer to the
stackblitz example here and it relevent article here.