skip to Main Content

I’m using the VS2022 template: Angular and ASP Core. I have not added any extra code. I’m trying to tweak the ports and settings to make it work in Docker.

Angular and ASP.NET Core

It runs perfectly without Docker.

When I create another project using containers:

containers enabled

Everything compiles and runs. It displays in Docker Desktop.
Successfully installed container

The backend can be tested and works with Swagger.

successful test in swagger

The frontend loads and runs but does not display the weather data. F12 reveals a Error 500 Internal Server Error.
no results returned from backend api

500 Internal Server Error

A breakpoint in the backend is hit when I use Swagger but not hit when I refresh the frontend.

So I think that the frontend can’t see the backend because they’re in containers right?

How do I fix this please? I think there is a variable, a path to the client that VS2022 can predict that is only determined when the container is created. If so how do I set this?

Here is the content of the Proxy.js

enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    enter image description here

    This answer is frustrating because I had tried this a few times without success. But I must have been looking at cached data even though I was doing rebuilds. I'm aware Angular does that sometimes but I thought I had handled it. :((


  2. It seems to me that the URL you are sending the request is invalid:

    enter image description here

    You have an API running on the port 32769:

    enter image description here

    Port 4200 is reserved for Angular Dev Server (serving static resources)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search