Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
Cant connect my docker API container to my Next.js container

When trying to orchestrate my Next.js app + Express Application with docker-compose, I get an error trying to connect to the backend service. This is how my docker-compose file looks like

UPDATE: I got to connect to the backend service through the apiv4 number, but the connection times out. Most likely because of CORS. But I still can't access through localhost

version: "3.9"

services:
  client:
    restart: always
    build:
        context: ./frontend
        dockerfile: Dockerfile
    container_name: frontend_image
    volumes:
        - ./frontend:/app
        - /app/node_modules
    ports:
        - 3000:3000
    depends_on:
        - api
    networks:
        - express-api
    environment:
      API_BASE_URL: ${API_BASE_URL}
      API_PORT: ${API_PORT}

  api:
    restart: always
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: server_image
    ports:
      - 4000:4000
    volumes:
      - ./backend:/app
      - /app/node_modules
    networks: 
      - express-api
    environment:
      TOKEN_SECRET: ${TOKEN_SECRET}
      DB_NAME: ${DB_NAME}
      CLUSTER_PASSWORD: ${CLUSTER_PASSWORD}
      API_PORT: ${API_PORT}

  nginx:
    restart: always
    depends_on:
        - api
        - client
    build:
        context: ./nginx
        dockerfile: Dockerfile
    ports:
        - 8080:80
    networks:
        - express-api

networks:
  express-api:
    driver: bridge

And when I try accessing the API from my next app I get this:

Terminal next.js warning

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda