Node API always returning Bad Request

Hi everyone,

I work with Traefik inside a docker-compose system. I use it to serve this app, where every component is inside a Docker container:

:wave: Typo: the frontend for Node API is actually named !

Here are links to my different (shortened) codes for this application:

  1. traefik.yml
  2. docker-compose.yml
  3. Node Dockerfile

What's the problem
I can successfully access my React application through Nginx, but my Node API keeps returning me a

Bad Gateway

I don't know why Traefik cannot reach my Node container, though it seems to be up and accessible:
Screenshot 2022-08-29 at 19.42.04

What I tried
Adding these two labels to the Node docker service, but didn't change anything, even by changing the port to 80 (which is what Node listens to)

- ""      
- "traefik.port=3000"

Any help will be greatly appreciated :slight_smile:

Configuration seems fine as all containers are running on traefik network and Traefik Docker Configuration Discovery is set to the same network.

The Node Docker image does not expose a port, so Traefik does not know where to route to. So adding the port declaration via label should be one step to the solution.

We use purchased TLS/SSL certificates, in my experience we had to add tls=true to make it work. But it seems for you it works for the other container without.

  --label 'traefik.enable=true'
  --label 'traefik.http.routers.node.tls=true'
  --label '' 

Make sure you have the right port :grin:

If this does not help, maybe try removing all the CORS stuff to see if it works without.

Thank you for your answer.

Actually the problem came from my NodeJS server which was effectively listening to the port 3000, but had an unneeded argument that prevented the server to listen to incoming requests:

const server = app.listen(port, 'localhost')

instead of

const server = app.listen(port)

My bad, hope it might help someone in the future :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.