We are experiencing an issue when we are using an HTTP proxy on Netlify. All proxied requests are failing with the following error:
“errorMessage”: “Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client”,
“Runtime.UnhandledPromiseRejection: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client”,
" at process. (/var/runtime/index.js:35:15)",
" at process.emit (events.js:314:20)",
" at processPromiseRejections (internal/process/promises.js:209:33)",
" at processTicksAndRejections (internal/process/task_queues.js:98:32)"
This issue appears only on Netlify, if you run the project locally or on Vercel there is no issue.
You can find the source code of a reproducible case on: GitHub - matthieuh/nextjs-netlify-issue
The application is deployed on
- Netlify on the following URL: https://60ba312324ad1700085094b0--vibrant-wiles-df48c4.netlify.app/
- Vercel on the following URL: https://nextjs-netlify-issue-2g1th3jty-matthieuh.vercel.app/
Any idea of the root cause of this issue?