Closed
Description
Steps to reproduce
Using TypeScript, this is valid but throws an error.
// options
onProxyRes: (proxyRes, req, res) => {
const incomingCookies = proxyRes.getHeader(SET_COOKIE_HEADER);
// etc
},
Expected behavior
- TypeScript doesn't expect
proxyRes.getHeader
,proxyRes.hasHeader
,proxyRes.setHeader
to be methods available. - TypeScript expects
proxyRes.headers
to be an array of strings.
Actual behavior
✖ uncaughtException (an exception was thrown but not caught) TypeError: proxyRes.getHeader is not a function
at ProxyServer.onProxyRes (proxy.ts)
Workaround
proxyRes.headers
works as expected, so adding this code works, but it would be cleaner to just have the correct types.
// options
onProxyRes: (
proxyRes: ServerResponse & { headers: { [name: string]: string[] } },
req,
res
) => {
const incomingCookies = proxyRes.headers[SET_COOKIE_HEADER];
// etc
},
I'm not sure what type the proxyRes
should be.
client info
I'm using latest Express.
Reproducible Demo
I can create one if necessary.
Metadata
Metadata
Assignees
Labels
No labels