http-proxy-middleware
http-proxy-middleware copied to clipboard
Cannot override options in the `onProxyReq` method.
trafficstars
Checks
- [X] I understand project setup issues should be asked on StackOverflow or in GitHub Discussions.
- [X] I updated to latest
http-proxy-middleware.
Describe the bug (be clear and concise)
Update the ip agent address dynamically on each request, but it didn't work
Step-by-step reproduction instructions
app.use(
'/',
createProxyMiddleware({
target: 'https://ip.tool.lu/',
changeOrigin: true,
followRedirects: true,
agent: new HttpsProxyAgent({
proxy: getRandomAgentProxy(),
}),
onProxyReq: (proxyReq, req, res, options) => {
// Update the ip agent address dynamically on each request
options.agent = new HttpsProxyAgent({
proxy: getRandomAgentProxy(),
});
}
}),
);
Expected behavior (be clear and concise)
Hope to update the agent ip dynamically
How is http-proxy-middleware used in your project?
basic express demo.
What http-proxy-middleware configuration are you using?
app.use(
'/',
createProxyMiddleware({
target: 'https://ip.tool.lu/',
changeOrigin: true,
followRedirects: true,
agent: new HttpsProxyAgent({
proxy: getRandomAgentProxy(),
}),
onProxyReq: (proxyReq, req, res, options) => {
// Update the ip agent address dynamically on each request
options.agent = new HttpsProxyAgent({
proxy: getRandomAgentProxy(),
});
}
}),
);
What OS/version and node/version are you seeing the problem?
OS: macOS 13.2.1
Node: 19.5.0
Additional context (optional)
No response
any updates, same issue
same issue