-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Running 'setHeader' during 'proxyReq' event fails for POST requests #908
Comments
@cdl what node version does this happen in? Could you write a reproducible test case? I want to establish if this is a deterministic issue and if not what conditions FULLY create it. Thanks! |
@jcrugzz Happens in node |
@cdl can you upgrade to |
@jcrugzz Just tested in |
@cdl sounds good, and if you can encapsulate it into a test that you can PR to this project that would get us closer to a solution :). Thanks for the update! |
I had the same issue after upgrading to 1.12.0, downgrading back to 1.11.3 resolved it for me. |
@stickystyle could you post a sample of the code that you use for |
@jcrugzz I've just made a scrubbed gist of the |
For me, this issue has gone away in the most recent v1.13.2 |
This PR tries to fix "Can't set headers after they are sent" errors. That are a lot of situations where this error can occurs. In my case, it is happening because I have others middlewares (in an expressjs application that tries to proxy requests). Some of those middlewares (like [passportjs](http://passportjs.org/), or [cors](https://www.npmjs.com/package/cors)) can run ```res.end()``` and when the proxy receive a response, it is already finished. So, it is necessary to test if we can write on the user response when the proxy response is ready. I think it could also fix http-party#930, http-party#1168, http-party#908
This PR tries to fix "Can't set headers after they are sent" errors. That are a lot of situations where this error can occurs. In my case, it is happening because I have others middlewares (in an expressjs application that tries to proxy requests). Some of those middlewares (like [passportjs](http://passportjs.org/), or [cors](https://www.npmjs.com/package/cors)) can run ```res.end()``` and when the proxy receive a response, it is already finished. So, it is necessary to test if we can write on the user response when the proxy response is ready. I think it could also fix #930, #1168, #908
This PR tries to fix "Can't set headers after they are sent" errors. That are a lot of situations where this error can occurs. In my case, it is happening because I have others middlewares (in an expressjs application that tries to proxy requests). Some of those middlewares (like [passportjs](http://passportjs.org/), or [cors](https://www.npmjs.com/package/cors)) can run ```res.end()``` and when the proxy receive a response, it is already finished. So, it is necessary to test if we can write on the user response when the proxy response is ready. I think it could also fix #930, #1168, #908
This PR tries to fix "Can't set headers after they are sent" errors. That are a lot of situations where this error can occurs. In my case, it is happening because I have others middlewares (in an expressjs application that tries to proxy requests). Some of those middlewares (like [passportjs](http://passportjs.org/), or [cors](https://www.npmjs.com/package/cors)) can run ```res.end()``` and when the proxy receive a response, it is already finished. So, it is necessary to test if we can write on the user response when the proxy response is ready. I think it could also fix #930, #1168, #908
Right now, it looks like trying to do a
setHeader
on the passed inproxyReq
forPOST
requests fails. (see below:)The following error is thrown when the above tries to execute:
This seems to work totally fine for
GET
requests, just notPOST
requests. Managed to hack around it at first by wrapping the.setHeader
call in check to make sureproxyReq._header
wasnull
, but it looks like that totally fails when Firefox tries to perform aPOST
request (the header doesn't get set).The same thing appears to happen when trying to do
res.setHeader
, as suggested by #819.The text was updated successfully, but these errors were encountered: