Skip to content

Don't respond with 200 when can't connect to target #21

@Hilzu

Description

@Hilzu

I'm running local-api-gateway with this docker-compose.yml:

services:
  local-api-gw:
    image: bref/local-api-gateway
    ports:
      - '4006:8000'
    environment:
      TARGET: 'lambda-service:8080'

  lambda-service:
    build:
      context: .

If local-api-gw can't connect to lambda-service it responds with 200 OK instead of failing the request. This is what the container logs:

local-api-gw-1  | Error: getaddrinfo ENOTFOUND lambda-service
local-api-gw-1  |     at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)

This is the response from local-api-gw logged in my application:

Response {
  status: 200,
  statusText: 'OK',
  headers: Headers {
    'x-powered-by': 'Express',
    'content-type': 'text/html; charset=utf-8',
    'content-length': '135',
    etag: 'W/"87-KwcCL8RZB16hzYJ7RIjYGD/bS2U"',
    date: 'Fri, 22 Aug 2025 07:09:59 GMT',
    connection: 'keep-alive',
    'keep-alive': 'timeout=5'
  },
  body: {"errno":-3008,"code":"ENOTFOUND","syscall":"getaddrinfo","hostname":"lambda-service","$metadata":{"attempts":1,"totalRetryDelay":0}},
  ok: true,
  url: 'http://localhost:4006/'
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions