Im wondering how to set up our Angular + .Net Core Web API environments for development with multiple developers.
Our Angular project must use an URL to consume the API. Nothing new about that. Locally for each of the developers, the API might use a different port. So I guess we need some local settings for each developer, so the Angular site uses the local port chosen by the developer. As a single developer its no problem, but we are 5 developers working on the same Angular + API.
Our current solution requires every developer to set the same URL i environment.ts and launchSettings.json. But is that really the best way? I mean, we cant always expect each developer to be able to use the same port.
Current solution:
environment.ts
export const environment = {
production: false,
baseUrl: "http://localhost:49421"
};
And then in our Angular services
myService.service.ts
export class MyService {
url = environment.baseUrl + "/api/location/";
... some code
}
and the launchSettings.json
"MyWeb.Api.Web": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:49421/"
}
So this works, but some developers have other ports chosen. But some developers complain that then they have to change the port to the same as what is in the environment.ts and that might change if some developer decides another local port. Is there a way where we can set it up so each developer can easily change the local port name without messing with the other developers settings?