re: Running React and Node.js in one shot with Docker! VIEW POST

re: Hi Vikas, Thanks for this! Was much needed. The docker images are running independently on ports 3000(client) and 5000(server). However, I am not ...

I think there is a typo. It should be http://localhost:5000


Yeah sorry. That's what I meant. That's what I have I have put in the client package.json

I don't know what's the issue. If you can share the code. I can look and fix it.

Your app looks fine. Please check that the PORT variable is set 5000 as you are also loading variables from .env file

Yeah bro, everything seems to be in order but I am not able to make requests to the Server container. Proxy is set correctly, PORT variables are set correctly. Dunno what seems to be the issue. It's working fine during localhost without the containers. Its also deployed on Heroku where it's working fine.

What machine do you use for development?

Hey found the solution man. Instead of "proxy": "localhost:5000", I replaced localhost with the Server's Docker service name from the docker-compose file. Now it looks something like this "proxy": "cfy_server:5000". It's working.

Bro. I seriously forgot about that. Awesome you found the issue.

Thanks for the heads up. I updated the post. I am amazed that no one encountered this issue before.

I came across this article because I am looking for a semi-unrelated react/express docker-compose issue that you solved via the above eg. http://docker-compose-service_name:xxxx.

No one anywhere said I needed to use my service name instead of localhost, but you did. Thank you for your post!

PS I included for entertainment my docker-compose file because they look almost identical, yet I didn't even come hear for help with that file; it was already finished. I came only for the package for the proxy fix.

version: '3.8'

    image: ads/node-express
    container_name: ads-server
      context: ./server
      dockerfile: Dockerfile.dev
      - "5000:5000"
      - ./server:/src/app
      - /src/app/node_modules
    restart: always
    image: ads/react
    stdin_open: true
    container_name: ads-client
      context: ./client
      dockerfile: Dockerfile.dev
      - "3000:3000"
      - ./client:/src/app
      - /src/app/node_modules
    restart: always
Code of Conduct Report abuse