Closed
Description
I want to dynamic routing and need to shutdown the proxy server like this.
const express = require('express');
const proxy = require('http-proxy-middleware');
const app = express();
const proxies = {};
proxies["/foo"] = proxy({target: 'http://localhost:8010'});
app.use((req, res, next)=>{
for(const path of Object.keys(proxies)){
if(path === req.url.substr(0, path.length)){
return proxies[path](req, res, next);
}
}
return next();
});
setTimeout(()=>{
// Suggestion: https://github.com/chimurai/http-proxy-middleware/blob/master/lib/index.js#L34
// middleware.proxy = httpProxy.createProxyServer({});
proxies["/foo"].proxy.close();
delete proxies["foo"];
}, 10*1000);
But the current implementation cannot access raw proxy server and cannot close the server.
so I suggest to add middleware.proxy
API.
Metadata
Metadata
Assignees
Labels
No labels