Angular Frontend Docker container doesn’t send/receive data from node express backend Docker container

so I am to docker containers…

I have a frontend application written in Angular.

With a proxy.conf.json holding:

/api": {
    "target": "http://127.0.0.1:3000",
    "secure": false
}

I also added in environment.prod.ts:

export const environment = {
  production: true,
  api: 'http://127.0.0.1:3000',
};

Finally my backend written in Node.js (Express).

In my app.js:

...
app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next()
});
...

When I build my apps, and add the frontend to Nginx local with the configuration file properly set up, and PM2 running backend my application running smoothly without any issues.

So following guides and documentations I created a container for my frontend.

Dockerfile:

FROM nginx
COPY dist /usr/share/nginx/html

and a container for my backend:

# Install the app dependencies in a full Node docker image
FROM node:10

WORKDIR "/app"
# Install OS updates 
RUN apt-get update 
 && apt-get dist-upgrade -y 
 && apt-get clean 
 && echo 'Finished installing dependencies'
# Copy package.json and package-lock.json
COPY package*.json ./
# Install app dependencies
RUN npm install --production
# Copy the dependencies into a Slim Node docker image
FROM node:10-slim

WORKDIR "/app"
# Install OS updates 
RUN apt-get update 
 && apt-get dist-upgrade -y 
 && apt-get clean 
 && echo 'Finished installing dependencies'
# Install app dependencies
COPY --from=0 /app/node_modules /app/node_modules
COPY . /app
ENV NODE_ENV production
ENV PORT 3000
USER node
EXPOSE 3000
CMD ["npm", "start"]

So as you may have guessed when I run both containers on my laptop (right after I finished the docker build) I can access each one of them but when I try to login I have a POST … 404 error (Not found).

If I run the frontend locally and the backend from the container it works like a charm….

I have googled a lot, and can’t seem to find an answer.

Thank you for your time and help,
Cheers.

Edit

As requested my Docker run commands:

docker run -d -p 3000:3000 myUserName/cis-backend
docker run -d -p 4200:80 myUserName/cis-frontend

Source: StackOverflow