-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Describe the bug
In 5.3.0 7b0a65e added custom logic that utilizes the proxyReq event to set the origin header. This throws an ERR_HTTP_HEADERS_SENT error for me when using using with https-proxy-agent (for example required in setups in which a corporate proxy is in place). I suspect the problem is the same as described in chimurai/http-proxy-middleware#957 and similar / related to the problem described in chimurai/http-proxy-middleware#472 (explanation provided in chimurai/http-proxy-middleware#472 (comment)).
When downgrading to 5.2.13 everything works again.
Reproduction
https://stackblitz.com/edit/github-sadccs?file=src%2FApp.vue,vite.config.js
Steps to reproduce
Run npm install
Replace https://example.org with an actual https proxy in vite.config.js (i don't know a public available one, sorry)
Run npm run dev
First click on the "Without proxy agent" button, you should see the expected result then.
Now click on the "With proxy agent" button, the ERR_HTTP_HEADERS_SENT should appear in the console.
System Info
Binaries:
Node: 18.15.0
npm: 9.5.0Used Package Manager
npm
Logs
Click to expand!
node:_http_outgoing:663
throw new ERR_HTTP_HEADERS_SENT('set');
^
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at new NodeError (node:internal/errors:399:5)
at ClientRequest.setHeader (node:_http_outgoing:663:11)
at setOriginHeader (file:///-------/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:61768:16)
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.