-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
fix(react-router): remove Content-Length
header from Single Fetch responses
#13902
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
Conversation
🦋 Changeset detectedLatest commit: ab93882 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Apologies! I accidentally messed up my previous PR #13658 and had to recreate it. Thanks in advance for your time and review! |
Content-Length
header from Single Fetch responses
Thanks! |
Thank you for merge! 🥳 |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
fixes: #12850
minimal reproduction: https://stackblitz.com/edit/github-pejjugrp?file=app%2Froutes%2Fhome.tsx
While investigating the cause of this issue, I discovered an interesting behavior: removing the Content-Length header from the response results in the application functioning correctly.
Upon further examination, I found the following description in the documentation for Node.js's http module:
In fact, when setting a clearly insufficient value such as Content-Length: 6, the response body appears to be affected accordingly.
As described in the issue, this becomes problematic when using response headers intended for redirect responses—such as those generated by authentication libraries—which often do not include a response body.
After considering how best to address this, I concluded that, regardless of whether the response is a redirect, the use of turbo-stream encoding can alter the expected body. Therefore, the most robust solution would be to remove the Content-Length header from all Single Fetch responses, which is what this PR implements.
Additional Notes:
There is a comment on the issue stating that the bug occurred in the development environment but not in production(node20, SSR enabled) . I have yet to determine the reason for this discrepancy.
Nevertheless, since I was able to reliably reproduce and fix the bug, I am submitting this pull request.