-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[Bug]: throwing a response with headers should preserve the headers #5356
Comments
Confirmed this isn't related to the RR integration - we still match As for whether this is the right behavior I'll need to check with @mjackson and @ryanflorence. It makes sense if you think about it from the standpoint of "the leaf route I'm going to transfer this over to Remix since it does turn out to be isolated there since the static handler is returning all the headers and we're just ignoring those below the boundary. |
FWIW the reason it works with |
Thank you for letting me know of that workaround! I tried a few variations and determined that if you want the headers to come through in this case you need:
I think the current behavior makes sense, but I'm not certain. It kinda feels like we're getting half of a feature. Part of the So we get response UI error bubbling, but not response header bubbling. I think I would be satisfied with the current behavior if the headers export also got a Instead, I think it would be better if the headers function that's called is always the one for the route that's matched, even if that route's loader fails. But that also feels kinda wrong because maybe we're not throwing a Response, maybe it's a runtime type error or something. So maybe the All that said, I really don't think it should be necessary to put a Now, that use case may be handled by the upcoming Anyway, I'm not certain what to recommend here, but the status quo feels wrong to me. |
I agree here. I'd love to re-think the approach there and see if we could be smarter based on which matched routes actually exported a
I think so? If you have a
|
This issue has been automatically marked stale because we haven't received a response from the original author in a while 🙈. This automation helps keep the issue tracker clean from issues that are not actionable. Please reach out if you have more information for us or you think this issue shouldn't be closed! 🙂 If you don't do so within 7 days, this issue will be automatically closed. |
This is definitely still relevant. |
Fixed by #6425 and should be available in 1.17.0. You'll have Also worth noting we are going to get #5473 merged as well. That was never the intended behavior (and pre v1 it didn't work that way) but since it got changed (presumably unintentionally) pre-v1 we're going to stick it behind a future flag. So then we'll use the deepest renderable |
🤖 Hello there, We just published version Thanks! |
What version of React Router are you using?
6.4+
Steps to Reproduce
I put an example with Remix together for this, but I think the fix will be in the router which is why I'm opening this issue here (maybe the repos should be merged afterall?).
Here's the repo: https://github.com/kentcdodds/throw-response-headers
Here's a loom explaining the issue: https://www.loom.com/share/20a07a160bd54ec6bf228dcdc46f1ef3
Expected Behavior
The short of it is, if you stick this in a loader:
The
x-my-header
doesn't show up in the response.But if you do this:
The
x-my-header
does show up.Actual Behavior
I would expect throwing a response to preserve the headers of that response (like it does with a redirect).
The text was updated successfully, but these errors were encountered: