chimurai / http-proxy-middleware

:zap: The one-liner node.js http-proxy middleware for connect, express, next.js and more
MIT License
10.7k stars 834 forks source link

BadRequestError: request aborted while calling /health endpoint #789

Closed codeonmoon closed 2 years ago

codeonmoon commented 2 years ago

Checks

Describe the bug (be clear and concise)

We have an express server where /health endpoint is present (GET method).

There is an external system which tries to call /health endpoint so that it can check the status and process further. But whenever other system tries to call it, we see below error in our log

BadRequestError: request aborted [HPM] Error occurred while proxying request to [ECONNRESET] (https://nodejs.org/api/errors.html#errors_common_system_errors)

Step-by-step reproduction instructions

1. calling the /health endpoint from a different system

Expected behavior (be clear and concise)

We should be able to get 200 status HTTP code, whenever we /health endpoint is called.

How is http-proxy-middleware used in your project?

We have an express server created as below: 
app.use('*', <middleware>, createProxyMiddleware({target, changeOrigin, onProxyReq: <function>, selfHandleResponse: true, onProxyRes: <function> })

Version -> http-proxy-middleware - ^2.0.0, I know this is not the latest version, but I tried that as well, it didn't solved the issue.

What http-proxy-middleware configuration are you using?

createProxyMiddleware({
    target,
    changeOrigin,
    onProxyReq: ****,
    selfHandleResponse: true,
    onProxyRes: ****,
  })

What OS/version and node/version are you seeing the problem?

Node Version -> v14.16.0-alpine3.13

Additional context (optional)

No response