local-api-gateway icon indicating copy to clipboard operation
local-api-gateway copied to clipboard

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

Open Hilzu opened this issue 5 months ago • 0 comments

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/'
}

Hilzu avatar Aug 22 '25 07:08 Hilzu