I have 2 containers:
- nginx(serving React app)
- node
Both inside the same docker-compose file.
When i run it locally ('npm start' for React and node index.js for backend) they work fine (backend receive request) - but when they are both in containers, something goes wrong..
** when i exec the nginx container - it does recognize http://server:5000/ endpoint (with curl)
docker-compose.yaml
version: "3.8"
services:
server:
build:
context: ./server
ports:
- "5000:5000"
networks:
- frontend
nginx:
build:
context: ./app
restart: always
ports:
- "80:80"
networks:
- frontend
networks:
frontend:
request part on frontend
async function sendMsg(...order){
await axios.put('http://server:5000/msg', order)
}
receive part on backend
app.put('/msg', (req, res) => {
console.log(req.body)
}