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.
Steps to reproduce
Using TypeScript, this is valid but throws an error.
Expected behavior
proxyRes.getHeader,proxyRes.hasHeader,proxyRes.setHeaderto be methods available.proxyRes.headersto 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.headersworks as expected, so adding this code works, but it would be cleaner to just have the correct types.I'm not sure what type the
proxyResshould be.client info
I'm using latest Express.
Reproducible Demo
I can create one if necessary.