Is this a bug report?
YES
Steps to reproduce
{
"name": "testbug",
"version": "0.0.0",
"dependencies": {
"express": "4.17.1",
"http-proxy-middleware": "1.1.1"
}
}
const express = require('express')
const app = express()
const { createProxyMiddleware } = require('http-proxy-middleware');
const options = {
router: function (req) {
return "http://INVALID";
}
};
app.use('/test', createProxyMiddleware (options));
app.listen(3000, () => {
console.log(`Example app listening at http://localhost:3000`)
})
Then :
Result : following runtime error is logged :
TypeError: Cannot read property 'host' of undefined
at ProxyServer.HttpProxyMiddleware.logError (C:\Users\dtoch\work\projects\pga\pga-iaf\iaf-hil-common-server-node\node_modules\.pnpm\[email protected][email protected]\node_modules\http-proxy-middleware\dist\http-proxy-middleware.js:141:87)
at ProxyServer.emit (C:\Users\dtoch\work\projects\pga\pga-iaf\iaf-hil-common-server-node\node_modules\.pnpm\[email protected]\node_modules\eventemitter3\index.js:210:27)
at ClientRequest.proxyError (C:\Users\dtoch\work\projects\pga\pga-iaf\iaf-hil-common-server-node\node_modules\.pnpm\[email protected][email protected]\node_modules\http-proxy\lib\http-proxy\passes\web-incoming.js:165:18)
Expected behavior
Not a TypeError runtime error should be generated but instead a normal error just indicating that the backend URL is invalid.
Actual behavior
TypeError: Cannot read property 'host' of undefined
Workaround
According to #512 part of [email protected] it should not be needed to define target if using router. However to avoid above error, it is still needed to set it to something e.g. XXX.
Setup
See above.
client info
target server info
target not defined (only using router section in options).
Is this a bug report?
YES
Steps to reproduce
Then :
Result : following runtime error is logged :
Expected behavior
Not a TypeError runtime error should be generated but instead a normal error just indicating that the backend URL is invalid.
Actual behavior
TypeError: Cannot read property 'host' of undefined
Workaround
According to #512 part of [email protected] it should not be needed to define target if using router. However to avoid above error, it is still needed to set it to something e.g. XXX.
Setup
See above.
client info
target server info
target not defined (only using router section in options).