Skip to content

Handler types are incorrectly coupled to express.js #719

@cdaringe

Description

@cdaringe

Checks

Describe the bug (be clear and concise)

TS compilation error occurs with compatible response & reply primitives.

I expect a type signature from createProxyMiddleware to yield: (req: IncomingMessage, res: http.ServerResponse, next?: ...) => void. However, the returned handler is explicitly coupled to express: (req: expresscore.Request, res: expresscore.Response), etc.

This is invalid.

When my server tries to then:

server.use((req, res, next) => myProxyMiddleware(req,res,next))`

i get a compilation error, because i'm using raw node interfaces (legit works!), but createProxyMiddleware demands express.js handlers.

Step-by-step reproduction instructions

TypeScript concern only

1. create a typescript project
2. install a non-express server, such as fastify & middie
3. try passing a `req: IncomingMessage` and `res: http.ServerResponse` into a `createProxyMiddleware(...)(req, res)`
4. observe compilation error

Expected behavior (be clear and concise)

No compilation error

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

top level dependency

What http-proxy-middleware configuration are you using?

programmatic use.

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

n/a

Additional context (optional)

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions