0
votes

I have a .NET Core api running on localhost:5000 thats configured to serve the static output from ng build. When in development I'd like to run my angular cli server with ng serve vs ng build --watch (mostly for convenience reasons).

I tried to run it with all the different proxy settings and suggestions out there but I think the issue is that my API is running on https and every suggestion defaults to secure: false. Is there something else I need to do to configure the proxy for https?

My proxy.conf.json should work pretty simply as the following since I dont need to change the origin or rewrite anything:

{
  "/api": {
    "target": "http://localhost:5000",
    "secure": true
  }
}

The error I get in the console is:

[HPM] Error occurred while trying to proxy request https://localhost:5000/api/values from localhost:4200 to https://localhost:5000 (EPROTO)

1

1 Answers

0
votes

since your API is running on https you should access it with httpS:

{
  "/api": {
    "target": "https://localhost:5000",
    "secure": false
  }
}

The "secure": false means that you accept that backend server is running on HTTPS with an invalid certificate; I suspect you do use an invalid (hand-made) certificate; reference: search secure: false here then see the explanation above.