There is a proxy issue since your localhost:3000 would to proxy to localhost:5000.
However, Once our frontend and backend are on seperate containers they would communicate through their container names.
So, in my package.json file (frontend), I've changed the proxy field from "http:// localhost:5000" to the container name (server) that I've given in the compose file, in my case its "mern-e-commerce_server".
I have 2 docker files present, 1 in the root directory of the project ./ and the other one in the ./frontend directory
Dockerfile [Backend ./]
# DOCKERFILE FOR THE BACKEND
FROM node:14.16.0
WORKDIR /usr/src/app/server
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 5000
CMD ["npm", "run","start"]
Dockefile [Frontend ./frontend]
# DOCKERFILE FOR THE FRONTEND
FROM node:14.16.0
WORKDIR /usr/src/app/client
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm","run", "start"]
@henri-edward
Docker Compose
This is the compose file that I used
Compose File
package.json
file (frontend), I've changed the proxy field from"http:// localhost:5000"
to the container name (server) that I've given in the compose file, in my case its "mern-e-commerce_server".I have 2 docker files present, 1 in the root directory of the project ./ and the other one in the ./frontend directory
Dockerfile [Backend ./]
Dockefile [Frontend ./frontend]
Check out my repo for better clarity on my directory tree