fix(rewrite): correctly update the status code during a rewrite #11352
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Closes #11306
The issue was caused by
this.status
inside theRenderContext
class. This status code is then passed to theSSResult
and used as initial status ofResponse
.This status code was passed by
route.ts
. It was a 404 because/foo
didn't match any route, however we still call the middleware because the user choserouting: 'manual'
.When we arrived to the middleware, we executed the rewrite, and we need update this status code in case we find a
RouteData
and aComponentInstance
.I moved the shared logic inside a new, private, function called
#executeRewrite
as per @florian-lefebvre suggestion.Testing
Added a new test case
Docs
N/A