next-runtime icon indicating copy to clipboard operation
next-runtime copied to clipboard

createProxyMiddleware on an api route is causing ERR_HTTP_HEADERS_SENT error

Open matthieuh opened this issue 4 years ago • 2 comments

Describe the bug When using createProxyMiddleware on an API route it's causing an ERR_HTTP_HEADERS_SENT error when trying to change the header on the proxy request. Cf discussion: https://github.com/vercel/next.js/discussions/14057

To Reproduce Steps to reproduce the behavior:

  1. Clone https://github.com/matthieuh/nextjs-netlify-issue
  2. Use it locally or deploying somewhere else than on Netlify (live Vercel) it works (ex: https://nextjs-netlify-issue-h8fdnwit0-matthieuh.vercel.app/)
  3. Deploy it now on Netlify (ex: https://vibrant-wiles-df48c4.netlify.app/)
  4. Build will succeed but if you try to click on a button making a call to the proxy it will fire the ERR_HTTP_HEADERS_SENT error

Expected behavior Expecting to have it working on Netlify well or at least understand the reason why it's not.

Versions

  • Next.js: 11.0.1
  • plugin: 3.7.1

matthieuh avatar Jul 22 '21 10:07 matthieuh

@matthieuh hey! so sorry no one seemed to touch on this. did you happen to find any sort of workaround? i know it's been awhile 😬 . we're in the middle of a plugin rewrite that hopes to address most of this existing plugin's issues so we're finally getting through to some of the lingering ones we've neglected. lmk - regardless, we will try to address this in the rewrite at some point!

lindsaylevine avatar Sep 24 '21 06:09 lindsaylevine

Hi @matthieuh Could you try upgrading to version 4 of the plugin as see if the problem still occurs? Thanks!

ascorbic avatar Dec 15 '21 11:12 ascorbic

Closing due to inactivity. If this is still an issue, please feel free to reopen this

ericapisani avatar Oct 13 '22 14:10 ericapisani