0

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.

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.