Differentiating environments
After finishing the task of deploying our backend, we need to change our frontend project to make requests to our cloud infrastructure. But here, a problem arises. We want to access our published backend when we are in production, but the team needs to continue accessing the API locally to develop new features in a more practical way. How can we have the best of both worlds?
The answer to this, once again, was thought up by the Angular team and is the creation of configuration files for each development environment.
Until version 14 of Angular, these files were already standard when creating the project (the ng new
command). However, to simplify new projects and reduce the learning curve, these files were removed for new projects.
But we shouldn’t worry because to add them, we can use the Angular CLI. On the command line, use the following command:
ng generate environments
After executing the preceding command, the Angular CLI creates...