-
Notifications
You must be signed in to change notification settings - Fork 876
Closed
Description
Checks
- I understand project setup issues should be asked on StackOverflow or in GitHub Discussions.
- I updated to latest
http-proxy-middleware.
Describe the bug (be clear and concise)
The onProxyRes option expects an OnProxyResCallback, which is defined as
export type OnProxyResCallback = (
proxyRes: http.IncomingMessage,
req: Request,
res: Response
) => void;The req and res parameters extend express's Request and Response.
The documentation demonstrates using responseInterceptor to build that callback. Although the onProxyRes is going to receive a Request instance, responseInterceptor only allows you to expect an http.IncomingMessage. It seems like you should be able to expect a Request for the req argument.
export function responseInterceptor(interceptor: Interceptor) {where Interceptor is
type Interceptor = (
buffer: Buffer,
proxyRes: http.IncomingMessage,
req: http.IncomingMessage,
res: http.ServerResponse
) => Promise<Buffer | string>;This came up as an issue for me because there is information in the express Request that I need to access in my onProxyRes callback, but can't in a type-safe manner.
Step-by-step reproduction instructions
n/aExpected behavior (be clear and concise)
responseInterceptor should type req as Request and res as Response.
How is http-proxy-middleware used in your project?
n/aWhat http-proxy-middleware configuration are you using?
n/aWhat OS/version and node/version are you seeing the problem?
n/aAdditional context (optional)
No response
Metadata
Metadata
Assignees
Labels
No labels