Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot override options in the onProxyReq method. #938

Open
2 tasks done
ghost opened this issue Sep 4, 2023 · 1 comment
Open
2 tasks done

Cannot override options in the onProxyReq method. #938

ghost opened this issue Sep 4, 2023 · 1 comment

Comments

@ghost
Copy link

ghost commented Sep 4, 2023

Checks

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

@squapllabs
Copy link

any updates, same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant