http-proxy-middleware
http-proxy-middleware copied to clipboard
How to destroy created proxy
I am using http-proxy-middleware this way:
let addons = {
myaddon1: {
proxy: proxy({
target: `http://localhost:${addonPort}`,
changeOrigin: true,
ws: true,
logLevel: "debug"
})
}
}
app.use('/:name/:type', function (req, res) {
if (addons[req.params.name]) {
addons[req.params.name].proxy(req, res);
} else {
res.send(`Add-on ${req.params.name} not found.`);
}
});
when i delete addons[req.params.name].proxy somehow the proxy is still serving websocket,
my question is how to completely destroy the proxy ?
I have this same issue. I tried to use express-dynamic-middleware and that will remove the route, but somehow the websockets do not get cleared. So while the normal routes work, any active websockets will not be purged.