Reputation: 8691
I have developed an angular 7 basic app and asp.net web api. Both these applications are running perfectly fine in isolation. I dont want to host my applications on IIS. I am trying to run both using thier local webserver. The angular app by default on ng serve , uses http://localhost:4200. The webapi uses a different port. My question is how do I make both the applications communicate since they are on different ports. I tried changing the port in the webapi to point to 4200 but when I do ng serve, i get a message saying it is already in use and please use another port. Could somebody help.
Upvotes: 0
Views: 199
Reputation: 8261
with ng serve
, you need --proxy-config
option to communicate to other port. If your .net server is on port 8080, create a proxy.conf.json
like below:
{
"/api": {
"target": "http://localhost:8080",
"secure": false,
"logLevel": "debug"
}
}
and run:
ng serve --proxy-config proxy.conf.json
When you access /api/*
via your Angular app, it bypasses to your .net server.
Upvotes: 2