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

ERR_HTTP_HEADERS_SENT from onProxyReq with https-proxy-agent #957

Open
2 tasks done
leonardo3dp opened this issue Dec 30, 2023 · 2 comments
Open
2 tasks done

ERR_HTTP_HEADERS_SENT from onProxyReq with https-proxy-agent #957

leonardo3dp opened this issue Dec 30, 2023 · 2 comments

Comments

@leonardo3dp
Copy link

Checks

Describe the bug (be clear and concise)

I can't change the headers using onProxyReq when I set the agent using https-proxy-agent

Step-by-step reproduction instructions

1. Configure proxy middleware with a https-proxy-agent agent
2. Add an onProxyReq handler that sets a header
3. Apply load with a larger number of threads/VUs than available sockets.

Expected behavior (be clear and concise)

No errors, perhaps timeouts due to socket availability.

How is http-proxy-middleware used in your project?

const express = require('express');
const { createProxyMiddleware } =  require('http-proxy-middleware');
const { HttpsProxyAgent } = require('https-proxy-agent');

const proxyAgent = new HttpsProxyAgent('http://111.111.111.:1111') ;

const apiHost = 'https://exemple.com';

const proxyMiddleware = createProxyMiddleware({
    agent: proxyAgent,
    target: apiHost,
    changeOrigin: true,
    onProxyReq: (proxyReq, req, res) => {
        proxyReq.setHeader('TEST', 'hello world');
    }
});

const server = express();
server.get('/', proxyMiddleware);

server.listen(3000);

What http-proxy-middleware configuration are you using?

{
    agent: proxyAgent,
    target: apiHost,
    changeOrigin: true,
    onProxyReq: (proxyReq, req, res) => {
        proxyReq.setHeader('TEST', 'hello world');
    }
}

What OS/version and node/version are you seeing the problem?

Node v16
OS: Windows 10

Additional context (optional)

No response

@squapllabs
Copy link

same issue even without using agent: proxyAgent,

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

3 participants
@leonardo3dp @squapllabs and others